View | Details | Raw Unified | Return to issue 118788
Collapse All | Expand All

(-)a/include/svx/svdlayer.hxx (+4 lines)
Lines 164-169 public: Link Here
164
    void               getVisibleLayersODF( SdrLayerIDSet& rOutSet) const;
164
    void               getVisibleLayersODF( SdrLayerIDSet& rOutSet) const;
165
    void               getPrintableLayersODF( SdrLayerIDSet& rOutSet) const;
165
    void               getPrintableLayersODF( SdrLayerIDSet& rOutSet) const;
166
    void               getLockedLayersODF( SdrLayerIDSet& rOutSet) const;
166
    void               getLockedLayersODF( SdrLayerIDSet& rOutSet) const;
167
168
    // Generates a bitfield for settings.xml from the SdrLayerIDSet.
169
    // Output is a uno sequence of BYTE (which is 'short' in API).
170
    void               QueryValue(const SdrLayerIDSet& rViewLayerSet, css::uno::Any& rAny);
167
};
171
};
168
172
169
#endif // INCLUDED_SVX_SVDLAYER_HXX
173
#endif // INCLUDED_SVX_SVDLAYER_HXX
(-)a/include/svx/svdsob.hxx (-3 / +1 lines)
Lines 82-92 public: Link Here
82
82
83
    void operator&=(const SdrLayerIDSet& r2ndSet);
83
    void operator&=(const SdrLayerIDSet& r2ndSet);
84
84
85
    // initialize this set with a uno sequence of sal_Int8
85
    // initialize this set with a uno sequence of sal_Int8 (e.g. as stored in settings.xml)
86
    void PutValue(const css::uno::Any & rAny);
86
    void PutValue(const css::uno::Any & rAny);
87
87
88
    // returns a uno sequence of sal_Int8
89
    void QueryValue(css::uno::Any & rAny) const;
90
};
88
};
91
89
92
#endif // INCLUDED_SVX_SVDSOB_HXX
90
#endif // INCLUDED_SVX_SVDSOB_HXX
(-)a/sd/qa/unit/misc-tests.cxx (+47 lines)
Lines 66-71 public: Link Here
66
    void testTdf38225();
66
    void testTdf38225();
67
    void testTdf101242_ODF();
67
    void testTdf101242_ODF();
68
    void testTdf101242_settings();
68
    void testTdf101242_settings();
69
    void testTdf119392();
69
70
70
    CPPUNIT_TEST_SUITE(SdMiscTest);
71
    CPPUNIT_TEST_SUITE(SdMiscTest);
71
    CPPUNIT_TEST(testTdf96206);
72
    CPPUNIT_TEST(testTdf96206);
Lines 77-82 public: Link Here
77
    CPPUNIT_TEST(testTdf38225);
78
    CPPUNIT_TEST(testTdf38225);
78
    CPPUNIT_TEST(testTdf101242_ODF);
79
    CPPUNIT_TEST(testTdf101242_ODF);
79
    CPPUNIT_TEST(testTdf101242_settings);
80
    CPPUNIT_TEST(testTdf101242_settings);
81
    CPPUNIT_TEST(testTdf119392);
80
    CPPUNIT_TEST_SUITE_END();
82
    CPPUNIT_TEST_SUITE_END();
81
83
82
virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override
84
virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override
Lines 488-493 void SdMiscTest::testTdf101242_settings() Link Here
488
    xDocShRef->DoClose();
490
    xDocShRef->DoClose();
489
}
491
}
490
492
493
void SdMiscTest::testTdf119392()
494
{
495
    // Loads a document which has two user layers "V--" and "V-L". Inserts a new layer "-P-" between them.
496
    // Checks, that the bitfields in the saved file have the bits in the correct order.
497
498
    sd::DrawDocShellRef xDocShRef = Load(m_directories.getURLFromSrc("/sd/qa/unit/data/tdf119392_InsertLayer.odg"), ODG);
499
    CPPUNIT_ASSERT_MESSAGE("Failed to load file.", xDocShRef.is());
500
    // Insert layer "-P-", not visible, printable, not locked
501
    SdrView* pView = xDocShRef -> GetViewShell()->GetView();
502
    pView -> InsertNewLayer("-P-", 6); // 0..4 standard layer, 5 layer "V--"
503
    SdrPageView* pPageView = pView -> GetSdrPageView();
504
    pPageView -> SetLayerVisible("-P-", false);
505
    pPageView -> SetLayerPrintable("-P-", true);
506
    pPageView -> SetLayerLocked("-P-", false);
507
    utl::TempFile aTempFile;
508
    aTempFile.EnableKillingFile();
509
    save(xDocShRef.get(), getFormat(ODG), aTempFile );
510
511
    // Verify correct bit order in bitfield in the items in settings.xml
512
    xmlDocPtr pXmlDoc = parseExport(aTempFile, "settings.xml");
513
    CPPUNIT_ASSERT_MESSAGE("Failed to get 'settings.xml'", pXmlDoc);
514
    const OString sPathStart("/office:document-settings/office:settings/config:config-item-set[@config:name='ooo:view-settings']/config:config-item-map-indexed[@config:name='Views']/config:config-item-map-entry");
515
    // First Byte is in order 'V-L -P- V-- measurelines controls backgroundobjects background layout'
516
    // Bits need to be: visible=10111111=0xbf=191 printable=01011111=0x5f=95 locked=10000000=0x80=128
517
    // The values in file are Base64 encoded.
518
    OUString sBase64;
519
    uno::Sequence<sal_Int8> aDecodedSeq;
520
    sBase64 = getXPathContent(pXmlDoc, sPathStart + "/config:config-item[@config:name='VisibleLayers']");
521
    CPPUNIT_ASSERT_MESSAGE( "Item VisibleLayers does not exists.", !sBase64.isEmpty());
522
    comphelper::Base64::decode(aDecodedSeq, sBase64);
523
    CPPUNIT_ASSERT_EQUAL( 0xbF, static_cast<sal_uInt8>(aDecodedSeq[0]) & 0xff); // & 0xff forces unambigious types for CPPUNIT_ASSERT_EQUAL
524
525
    sBase64 = getXPathContent(pXmlDoc, sPathStart + "/config:config-item[@config:name='PrintableLayers']");
526
    CPPUNIT_ASSERT_MESSAGE( "Item PrintableLayers does not exists.", !sBase64.isEmpty());
527
    comphelper::Base64::decode(aDecodedSeq, sBase64);
528
    CPPUNIT_ASSERT_EQUAL( 0x5f, static_cast<sal_uInt8>(aDecodedSeq[0]) & 0xff);
529
530
    sBase64 = getXPathContent(pXmlDoc, sPathStart + "/config:config-item[@config:name='LockedLayers']");
531
    CPPUNIT_ASSERT_MESSAGE( "Item LockedLayers does not exists.", !sBase64.isEmpty());
532
    comphelper::Base64::decode(aDecodedSeq, sBase64);
533
    CPPUNIT_ASSERT_EQUAL( 0x80, static_cast<sal_uInt8>(aDecodedSeq[0]) & 0xff);
534
535
    xDocShRef->DoClose();
536
}
537
491
CPPUNIT_TEST_SUITE_REGISTRATION(SdMiscTest);
538
CPPUNIT_TEST_SUITE_REGISTRATION(SdMiscTest);
492
539
493
CPPUNIT_PLUGIN_IMPLEMENT();
540
CPPUNIT_PLUGIN_IMPLEMENT();
(-)a/sd/source/ui/view/frmview.cxx (-3 / +4 lines)
Lines 395-408 void FrameView::WriteUserDataSequence ( css::uno::Sequence < css::beans::Propert Link Here
395
    aUserData.addValue( sUNO_View_EliminatePolyPointLimitAngle, makeAny( static_cast<sal_Int32>(GetEliminatePolyPointLimitAngle()) ) );
395
    aUserData.addValue( sUNO_View_EliminatePolyPointLimitAngle, makeAny( static_cast<sal_Int32>(GetEliminatePolyPointLimitAngle()) ) );
396
    aUserData.addValue( sUNO_View_IsEliminatePolyPoints, makeAny( IsEliminatePolyPoints() ) );
396
    aUserData.addValue( sUNO_View_IsEliminatePolyPoints, makeAny( IsEliminatePolyPoints() ) );
397
397
398
    SdrLayerAdmin& rLayerAdmin = getSdrModelFromSdrView().GetLayerAdmin();
398
    Any aAny;
399
    Any aAny;
399
    GetVisibleLayers().QueryValue( aAny );
400
    rLayerAdmin.QueryValue(GetVisibleLayers(), aAny);
400
    aUserData.addValue( sUNO_View_VisibleLayers, aAny );
401
    aUserData.addValue( sUNO_View_VisibleLayers, aAny );
401
402
402
    GetPrintableLayers().QueryValue( aAny );
403
    rLayerAdmin.QueryValue(GetPrintableLayers(), aAny);
403
    aUserData.addValue( sUNO_View_PrintableLayers, aAny );
404
    aUserData.addValue( sUNO_View_PrintableLayers, aAny );
404
405
405
    GetLockedLayers().QueryValue( aAny );
406
    rLayerAdmin.QueryValue(GetLockedLayers(), aAny);
406
    aUserData.addValue( sUNO_View_LockedLayers, aAny );
407
    aUserData.addValue( sUNO_View_LockedLayers, aAny );
407
408
408
    aUserData.addValue( sUNO_View_NoAttribs, makeAny( IsNoAttribs() ) );
409
    aUserData.addValue( sUNO_View_NoAttribs, makeAny( IsNoAttribs() ) );
(-)a/svx/source/svdraw/svdlayer.cxx (-28 / +47 lines)
Lines 43-49 void SdrLayerIDSet::operator&=(const SdrLayerIDSet& r2ndSet) Link Here
43
    }
43
    }
44
}
44
}
45
45
46
/** initialize this set with a uno sequence of sal_Int8
46
/** initialize this set with a uno sequence of sal_Int8 (e.g. as stored in settings.xml)
47
*/
47
*/
48
void SdrLayerIDSet::PutValue( const css::uno::Any & rAny )
48
void SdrLayerIDSet::PutValue( const css::uno::Any & rAny )
49
{
49
{
Lines 67-98 void SdrLayerIDSet::PutValue( const css::uno::Any & rAny ) Link Here
67
    }
67
    }
68
}
68
}
69
69
70
/** returns a uno sequence of sal_Int8
71
*/
72
void SdrLayerIDSet::QueryValue( css::uno::Any & rAny ) const
73
{
74
    sal_Int16 nNumBytesSet = 0;
75
    sal_Int16 nIndex;
76
    for( nIndex = 31; nIndex >= 00; nIndex-- )
77
    {
78
        if( 0 != aData[nIndex] )
79
        {
80
            nNumBytesSet = nIndex + 1;
81
            break;
82
        }
83
    }
84
85
    css::uno::Sequence< sal_Int8 > aSeq( nNumBytesSet );
86
87
    for( nIndex = 0; nIndex < nNumBytesSet; nIndex++ )
88
    {
89
        aSeq[nIndex] = static_cast<sal_Int8>(aData[nIndex]);
90
    }
91
92
    rAny <<= aSeq;
93
}
94
95
96
SdrLayer::SdrLayer(SdrLayerID nNewID, const OUString& rNewName) :
70
SdrLayer::SdrLayer(SdrLayerID nNewID, const OUString& rNewName) :
97
    maName(rNewName), pModel(nullptr), nType(0), nID(nNewID)
71
    maName(rNewName), pModel(nullptr), nType(0), nID(nNewID)
98
{
72
{
Lines 366-370 void SdrLayerAdmin::getLockedLayersODF( SdrLayerIDSet& rOutSet) const Link Here
366
    }
340
    }
367
}
341
}
368
342
343
    // Generates a bitfield for settings.xml from the SdrLayerIDSet.
344
    // Output is a uno sequence of BYTE (which is 'short' in API).
345
void SdrLayerAdmin::QueryValue(const SdrLayerIDSet& rViewLayerSet, css::uno::Any& rAny)
346
{
347
    // tdf#119392 The SdrLayerIDSet in a view is ordered according LayerID, but in file
348
    // the bitfield is interpreted in order of layers in <draw:layer-set>.
349
    // First generate a new bitfield based on rViewLayerSet in the needed order.
350
    sal_uInt8 aTmp[32]; // 256 bits in settings.xml makes byte 0 to 31
351
    for (auto nIndex = 0; nIndex <32; nIndex++)
352
    {
353
        aTmp[nIndex] = 0;
354
    }
355
    sal_uInt8 nByteIndex = 0;
356
    sal_uInt8 nBitpos = 0;
357
    sal_uInt16 nLayerPos = 0; // Position of the layer in member aLayer and in <draw:layer-set> in file
358
    for( SdrLayer* pCurrentLayer : aLayer )
359
    {
360
        SdrLayerID nCurrentID = pCurrentLayer->GetID();
361
        if ( rViewLayerSet.IsSet(nCurrentID) )
362
        {
363
            nLayerPos = GetLayerPos(pCurrentLayer);
364
            nByteIndex = nLayerPos / 8;
365
            if (nByteIndex > 31)
366
                continue; // skip position, if too large for bitfield
367
            nBitpos = nLayerPos % 8;
368
            aTmp[nByteIndex] |= (1 << nBitpos);
369
        }
370
    }
371
372
    // Second transform the bitfield to byte sequence, same as in previous version of QueryValue
373
    sal_uInt8 nNumBytesSet = 0;
374
    for( auto nIndex = 31; nIndex >= 0; nIndex--)
375
    {
376
        if( 0 != aTmp[nIndex] )
377
        {
378
            nNumBytesSet = nIndex + 1;
379
            break;
380
        }
381
    }
382
    css::uno::Sequence< sal_Int8 > aSeq( nNumBytesSet );
383
    for( auto nIndex = 0; nIndex < nNumBytesSet; nIndex++ )
384
    {
385
        aSeq[nIndex] = static_cast<sal_Int8>(aTmp[nIndex]);
386
    }
387
    rAny <<= aSeq;
388
}
369
389
370
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
390
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
371
- 

Return to issue 118788