summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2013-03-15 15:17:38 +0000
committerNoel Power <noel.power@suse.com>2013-03-15 15:22:52 +0000
commitd2cccde341af33b72378f3e7b0e8dd9ff1cd5e65 (patch)
treeef9229b7c6406461643f5c237e24d6e4b889db62
parentf2d9db4ef951d04c63733b08dd8746c196dd5f05 (diff)
follow patch for fdo#38385 attempt to detect rtl
tbh this is somewhat of an optimistic attempt to swap start and end borders if needed. I am not at all sure though that I am dectecting the RTL-ness of a cell in the correct way. There are some comments in the code in any case that reflect my uncertainty ( hopefully they will be of use if/when some tweak is needed ) Change-Id: Ic3099fbab08e46899ca311c81edbcad9bf5ab2a6
-rw-r--r--sc/source/filter/inc/stylesbuffer.hxx4
-rw-r--r--sc/source/filter/oox/stylesbuffer.cxx41
2 files changed, 39 insertions, 6 deletions
diff --git a/sc/source/filter/inc/stylesbuffer.hxx b/sc/source/filter/inc/stylesbuffer.hxx
index 4b49e0d50006..c9223c436395 100644
--- a/sc/source/filter/inc/stylesbuffer.hxx
+++ b/sc/source/filter/inc/stylesbuffer.hxx
@@ -456,7 +456,9 @@ struct BorderLineModel
/** Contains XML attributes of a complete cell border. */
struct BorderModel
{
+ BorderLineModel maStart; /// Start line format.
BorderLineModel maLeft; /// Left line format.
+ BorderLineModel maEnd; /// End line format.
BorderLineModel maRight; /// Right line format.
BorderLineModel maTop; /// Top line format.
BorderLineModel maBottom; /// Bottom line format.
@@ -511,7 +513,7 @@ public:
void importDxfBorder( sal_Int32 nElement, SequenceInputStream& rStrm );
/** Final processing after import of all style settings. */
- void finalizeImport();
+ void finalizeImport( bool bRTL );
/** Returns the border model structure. */
inline const BorderModel& getModel() const { return maModel; }
diff --git a/sc/source/filter/oox/stylesbuffer.cxx b/sc/source/filter/oox/stylesbuffer.cxx
index 8c8a0b9b90e8..3b81f2cfca23 100644
--- a/sc/source/filter/oox/stylesbuffer.cxx
+++ b/sc/source/filter/oox/stylesbuffer.cxx
@@ -1577,7 +1577,9 @@ void BorderLineModel::setBiffStyle( sal_Int32 nLineStyle )
// ----------------------------------------------------------------------------
BorderModel::BorderModel( bool bDxf ) :
+ maStart( bDxf ),
maLeft( bDxf ),
+ maEnd( bDxf ),
maRight( bDxf ),
maTop( bDxf ),
maBottom( bDxf ),
@@ -1703,8 +1705,26 @@ void Border::importDxfBorder( sal_Int32 nElement, SequenceInputStream& rStrm )
}
}
-void Border::finalizeImport()
+void Border::finalizeImport( bool bRTL )
{
+ // Swap left/right <-> start/end borders based on RTL
+ if ( maModel.maStart.mbUsed || maModel.maEnd.mbUsed )
+ {
+ if ( bRTL )
+ {
+ if ( maModel.maStart.mbUsed )
+ maModel.maRight = maModel.maStart;
+ if ( maModel.maEnd.mbUsed )
+ maModel.maLeft = maModel.maEnd;
+ }
+ else
+ {
+ if ( maModel.maStart.mbUsed )
+ maModel.maLeft = maModel.maStart;
+ if ( maModel.maEnd.mbUsed )
+ maModel.maRight = maModel.maEnd;
+ }
+ }
maApiData.mbBorderUsed = maModel.maLeft.mbUsed || maModel.maRight.mbUsed || maModel.maTop.mbUsed || maModel.maBottom.mbUsed;
maApiData.mbDiagUsed = maModel.maDiagonal.mbUsed;
@@ -1800,9 +1820,9 @@ BorderLineModel* Border::getBorderLine( sal_Int32 nElement )
switch( nElement )
{
case XLS_TOKEN( left ): return &maModel.maLeft;
- case XLS_TOKEN( start ): return &maModel.maLeft;
+ case XLS_TOKEN( start ): return &maModel.maStart;
case XLS_TOKEN( right ): return &maModel.maRight;
- case XLS_TOKEN( end ): return &maModel.maRight;
+ case XLS_TOKEN( end ): return &maModel.maEnd;
case XLS_TOKEN( top ): return &maModel.maTop;
case XLS_TOKEN( bottom ): return &maModel.maBottom;
case XLS_TOKEN( diagonal ): return &maModel.maDiagonal;
@@ -2519,13 +2539,22 @@ void Dxf::finalizeImport()
{
if( mxFont.get() )
mxFont->finalizeImport();
+ bool bRTL = false;
// number format already finalized by the number formats buffer
if( mxAlignment.get() )
+ {
mxAlignment->finalizeImport();
+ // how do we detect RTL when text dir is OOX_XF_CONTEXT? ( seems you
+ // would need access to the cell content, which we don't here )
+ if ( mxAlignment->getModel().mnTextDir == OOX_XF_TEXTDIR_RTL )
+ bRTL = true;
+ }
if( mxProtection.get() )
mxProtection->finalizeImport();
if( mxBorder.get() )
- mxBorder->finalizeImport();
+ {
+ mxBorder->finalizeImport( bRTL );
+ }
if( mxFill.get() )
mxFill->finalizeImport();
}
@@ -3057,7 +3086,9 @@ void StylesBuffer::finalizeImport()
// number formats
maNumFmts.finalizeImport();
// borders and fills
- maBorders.forEachMem( &Border::finalizeImport );
+ // is there a document wide RTL setting that we
+ // would/could need to pass to finalizeImport here ?
+ maBorders.forEachMem( &Border::finalizeImport, false );
maFills.forEachMem( &Fill::finalizeImport );
// style XFs and cell XFs
maStyleXfs.forEachMem( &Xf::finalizeImport );