[Libreoffice-commits] core.git: 9 commits - include/editeng include/oox include/svtools include/svx oox/source sfx2/source svtools/source svx/source sw/source
Tomaž Vajngerl
quikee at gmail.com
Sun Sep 15 06:37:40 PDT 2013
include/editeng/tstpitem.hxx | 5
include/oox/crypto/DocumentDecryption.hxx | 2
include/oox/crypto/Standard2007Engine.hxx | 5
include/svtools/ruler.hxx | 75 +-
include/svx/ruler.hxx | 19
include/svx/rulritem.hxx | 86 +-
oox/source/core/filterbase.cxx | 3
oox/source/core/filterdetect.cxx | 4
oox/source/core/xmlfilterbase.cxx | 4
oox/source/crypto/DocumentDecryption.cxx | 47 -
oox/source/crypto/Standard2007Engine.cxx | 39 -
sfx2/source/dialog/filedlghelper.cxx | 2
svtools/source/control/ruler.cxx | 731 +++++++++--------------
svx/source/dialog/rulritem.cxx | 251 +++++---
svx/source/dialog/svxruler.cxx | 929 +++++++++++++++++-------------
sw/source/ui/uiview/viewtab.cxx | 29
16 files changed, 1180 insertions(+), 1051 deletions(-)
New commits:
commit 13aedd1d0ec1ef4c5687c207eb1d9c986c1299d9
Author: Tomaž Vajngerl <quikee at gmail.com>
Date: Sat Sep 14 13:52:58 2013 +0200
Save should encrypt OOXML document if it was loaded encrypted.
Currently Agile encryption is not supported, so all documents
loaded with "agile" encryption will be encrypted with "standard"
encryption when they are saved afterwards.
Change-Id: Id0477f43c00ed70032ca6b3390eebb1105d5ffa7
diff --git a/include/oox/crypto/DocumentDecryption.hxx b/include/oox/crypto/DocumentDecryption.hxx
index 768cdbf..1502c41 100644
--- a/include/oox/crypto/DocumentDecryption.hxx
+++ b/include/oox/crypto/DocumentDecryption.hxx
@@ -59,7 +59,7 @@ public:
bool readEncryptionInfo();
bool generateEncryptionKey(const OUString& rPassword);
- com::sun::star::uno::Sequence< com::sun::star::beans::NamedValue > createEncryptionData();
+ com::sun::star::uno::Sequence< com::sun::star::beans::NamedValue > createEncryptionData(const OUString& rPassword);
static bool checkEncryptionData( const com::sun::star::uno::Sequence< com::sun::star::beans::NamedValue >& rEncryptionData );
};
diff --git a/include/oox/crypto/Standard2007Engine.hxx b/include/oox/crypto/Standard2007Engine.hxx
index c53ec22..563a710 100644
--- a/include/oox/crypto/Standard2007Engine.hxx
+++ b/include/oox/crypto/Standard2007Engine.hxx
@@ -89,11 +89,6 @@ public:
StandardEncryptionInfo& getInfo();
- static bool checkEncryptionData(
- std::vector<sal_uInt8> key, sal_uInt32 keySize,
- std::vector<sal_uInt8> encryptedVerifier, sal_uInt32 verifierSize,
- std::vector<sal_uInt8> encryptedHash, sal_uInt32 hashSize );
-
virtual bool generateEncryptionKey(const OUString& rPassword);
virtual bool writeEncryptionInfo(
diff --git a/oox/source/core/filterbase.cxx b/oox/source/core/filterbase.cxx
index ff498af..1eee845 100644
--- a/oox/source/core/filterbase.cxx
+++ b/oox/source/core/filterbase.cxx
@@ -545,7 +545,8 @@ void FilterBase::setMediaDescriptor( const Sequence< PropertyValue >& rMediaDesc
OUString sFilterName = mxImpl->maMediaDesc.getUnpackedValueOrDefault( "FilterName", OUString() );
try
{
- Reference< XNameAccess > xFilters( Reference<XMultiServiceFactory>(getComponentContext()->getServiceManager(), UNO_QUERY_THROW)->createInstance("com.sun.star.document.FilterFactory" ), UNO_QUERY_THROW );
+ Reference<XMultiServiceFactory> xFactory(getComponentContext()->getServiceManager(), UNO_QUERY_THROW);
+ Reference<XNameAccess> xFilters(xFactory->createInstance("com.sun.star.document.FilterFactory" ), UNO_QUERY_THROW );
Any aValues = xFilters->getByName( sFilterName );
Sequence<PropertyValue > aPropSeq;
aValues >>= aPropSeq;
diff --git a/oox/source/core/filterdetect.cxx b/oox/source/core/filterdetect.cxx
index 7dd3f92..154cee0 100644
--- a/oox/source/core/filterdetect.cxx
+++ b/oox/source/core/filterdetect.cxx
@@ -286,8 +286,8 @@ PasswordVerifier::PasswordVerifier( DocumentDecryption& aDecryptor ) :
comphelper::DocPasswordVerifierResult PasswordVerifier::verifyPassword( const OUString& rPassword, Sequence<NamedValue>& rEncryptionData )
{
- if( mDecryptor.generateEncryptionKey(rPassword) )
- rEncryptionData = mDecryptor.createEncryptionData();
+ if(mDecryptor.generateEncryptionKey(rPassword))
+ rEncryptionData = mDecryptor.createEncryptionData(rPassword);
return rEncryptionData.hasElements() ? comphelper::DocPasswordVerifierResult_OK : comphelper::DocPasswordVerifierResult_WRONG_PASSWORD;
}
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index 763090a..109e9b1 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -657,7 +657,7 @@ Reference<XStream> XmlFilterBase::implGetOutputStream( MediaDescriptor& rMediaDe
OUString aPassword;
for (int i=0; i<aMediaEncData.getLength(); i++)
{
- if (aMediaEncData[i].Name == "Password")
+ if (aMediaEncData[i].Name == "OOXPassword")
{
Any& any = aMediaEncData[i].Value;
any >>= aPassword;
@@ -690,7 +690,7 @@ bool XmlFilterBase::implFinalizeExport( MediaDescriptor& rMediaDescriptor )
for (int i=0; i<aMediaEncData.getLength(); i++)
{
- if (aMediaEncData[i].Name == "Password")
+ if (aMediaEncData[i].Name == "OOXPassword")
{
Any& any = aMediaEncData[i].Value;
any >>= aPassword;
diff --git a/oox/source/crypto/DocumentDecryption.cxx b/oox/source/crypto/DocumentDecryption.cxx
index 1cb6481..0d1c729 100644
--- a/oox/source/crypto/DocumentDecryption.cxx
+++ b/oox/source/crypto/DocumentDecryption.cxx
@@ -202,23 +202,9 @@ DocumentDecryption::DocumentDecryption(oox::ole::OleStorage& rOleStorage, Refere
mCryptoType(UNKNOWN)
{}
-bool DocumentDecryption::checkEncryptionData(const Sequence<NamedValue>& rEncryptionData)
+bool DocumentDecryption::checkEncryptionData(const Sequence<NamedValue>& /*rEncryptionData*/)
{
- SequenceAsHashMap aHashData( rEncryptionData );
- OUString type = aHashData.getUnpackedValueOrDefault( "CryptoType", OUString("Unknown") );
- if (type == "Standard")
- {
- Sequence<sal_Int8> aKeySeq = aHashData.getUnpackedValueOrDefault( "AES128EncryptionKey", Sequence<sal_Int8>() );
- Sequence<sal_Int8> aVerifierSeq = aHashData.getUnpackedValueOrDefault( "AES128EncryptionVerifier", Sequence<sal_Int8>() );
- Sequence<sal_Int8> aHashSeq = aHashData.getUnpackedValueOrDefault( "AES128EncryptionVerifierHash", Sequence<sal_Int8>() );
-
- vector<sal_uInt8> key = convertToVector(aKeySeq);
- vector<sal_uInt8> verifier = convertToVector(aVerifierSeq);
- vector<sal_uInt8> hash = convertToVector(aHashSeq);
-
- return Standard2007Engine::checkEncryptionData( key, key.size(), verifier, verifier.size(), hash, hash.size() );
- }
- return type == "Agile";
+ return false;
}
bool DocumentDecryption::generateEncryptionKey(const OUString& rPassword)
@@ -363,30 +349,21 @@ bool DocumentDecryption::readEncryptionInfo()
return bResult;
}
-Sequence<NamedValue> DocumentDecryption::createEncryptionData()
+Sequence<NamedValue> DocumentDecryption::createEncryptionData(const OUString& rPassword)
{
- Sequence<NamedValue> aResult;
-
- vector<sal_uInt8>& key = mEngine->getKey();
+ SequenceAsHashMap aEncryptionData;
- if (key.size() > 0)
+ if (mCryptoType == AGILE)
{
- SequenceAsHashMap aEncryptionData;
- if (mCryptoType == AGILE)
- {
- aEncryptionData["CryptoType"] <<= OUString("Agile");
- aEncryptionData["AES128EncryptionKey"] <<= Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( &key[0] ), key.size() );
- aResult = aEncryptionData.getAsConstNamedValueList();
- }
- else if (mCryptoType == STANDARD_2007)
- {
- aEncryptionData["CryptoType"] <<= OUString("Standard");
- aEncryptionData["AES128EncryptionKey"] <<= Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( &key[0] ), key.size() );
- aResult = aEncryptionData.getAsConstNamedValueList();
- }
+ aEncryptionData["CryptoType"] <<= OUString("Agile");
+ }
+ else if (mCryptoType == STANDARD_2007)
+ {
+ aEncryptionData["CryptoType"] <<= OUString("Standard");
}
- return aResult;
+ aEncryptionData["OOXPassword"] <<= rPassword;
+ return aEncryptionData.getAsConstNamedValueList();
}
bool DocumentDecryption::decrypt(Reference<XStream> xDocumentStream)
diff --git a/oox/source/crypto/Standard2007Engine.cxx b/oox/source/crypto/Standard2007Engine.cxx
index 3c17bb6..b437846 100644
--- a/oox/source/crypto/Standard2007Engine.cxx
+++ b/oox/source/crypto/Standard2007Engine.cxx
@@ -164,16 +164,22 @@ bool Standard2007Engine::generateEncryptionKey(const OUString& password)
mInfo.verifier.encryptedVerifier + ENCRYPTED_VERIFIER_LENGTH,
encryptedVerifier.begin());
- vector<sal_uInt8> encryptedVerifierHash(ENCRYPTED_VERIFIER_HASH_LENGTH);
+ vector<sal_uInt8> encryptedHash(ENCRYPTED_VERIFIER_HASH_LENGTH);
std::copy(
mInfo.verifier.encryptedVerifierHash,
mInfo.verifier.encryptedVerifierHash + ENCRYPTED_VERIFIER_HASH_LENGTH,
- encryptedVerifierHash.begin());
+ encryptedHash.begin());
- return checkEncryptionData(
- mKey, mKey.size(),
- encryptedVerifier, encryptedVerifier.size(),
- encryptedVerifierHash, encryptedVerifierHash.size() );
+ vector<sal_uInt8> verifier(encryptedVerifier.size(), 0);
+ Decrypt::aes128ecb(verifier, encryptedVerifier, mKey);
+
+ vector<sal_uInt8> verifierHash(encryptedHash.size(), 0);
+ Decrypt::aes128ecb(verifierHash, encryptedHash, mKey);
+
+ vector<sal_uInt8> hash(RTL_DIGEST_LENGTH_SHA1, 0);
+ sha1(hash, verifier);
+
+ return std::equal( hash.begin(), hash.end(), verifierHash.begin() );
}
bool Standard2007Engine::decrypt(
@@ -199,27 +205,6 @@ bool Standard2007Engine::decrypt(
return true;
}
-bool Standard2007Engine::checkEncryptionData(
- vector<sal_uInt8> key, sal_uInt32 keySize,
- vector<sal_uInt8> encryptedVerifier, sal_uInt32 verifierSize,
- vector<sal_uInt8> encryptedHash, sal_uInt32 hashSize )
-{
- // the only currently supported algorithm needs key size 128
- if ( keySize != 16 || verifierSize != 16 )
- return false;
-
- vector<sal_uInt8> verifier(verifierSize, 0);
- Decrypt::aes128ecb(verifier, encryptedVerifier, key);
-
- vector<sal_uInt8> verifierHash(hashSize, 0);
- Decrypt::aes128ecb(verifierHash, encryptedHash, key);
-
- vector<sal_uInt8> hash(RTL_DIGEST_LENGTH_SHA1, 0);
- sha1(hash, verifier);
-
- return std::equal( hash.begin(), hash.end(), verifierHash.begin() );
-}
-
bool Standard2007Engine::writeEncryptionInfo(const OUString& password, BinaryXOutputStream& rStream)
{
mInfo.header.flags = ENCRYPTINFO_AES | ENCRYPTINFO_CRYPTOAPI;
diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx
index 77e2a14..81bf474 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -2625,7 +2625,7 @@ ErrCode RequestPassword(const SfxFilter* pCurrentFilter, OUString& aURL, SfxItem
if ( lclSupportsOOXMLEncryption( pCurrentFilter->GetFilterName() ) )
{
::comphelper::SequenceAsHashMap aHashData;
- aHashData[ OUString( "Password" ) ] <<= pPasswordRequest->getPassword();
+ aHashData[ OUString( "OOXPassword" ) ] <<= pPasswordRequest->getPassword();
pSet->Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, uno::makeAny( aHashData.getAsConstNamedValueList() ) ) );
}
else
commit e0a43dff646515bbbcd2099b6fc095a7a89b84f9
Author: Tomaž Vajngerl <quikee at gmail.com>
Date: Fri Sep 13 22:12:51 2013 +0200
Use vector instead of scoped_array to hold ruler items
Change-Id: I51f8d1d22da5f869e9937813de9649fddae1ffda
diff --git a/include/editeng/tstpitem.hxx b/include/editeng/tstpitem.hxx
index 2541057..ee6ef7f 100644
--- a/include/editeng/tstpitem.hxx
+++ b/include/editeng/tstpitem.hxx
@@ -140,6 +140,11 @@ public:
const SvxTabStop& operator[]( const sal_uInt16 nPos ) const
{ return maTabStops[nPos]; }
+ const SvxTabStop& At( const sal_uInt16 nPos ) const
+ {
+ return maTabStops[nPos];
+ }
+
// "pure virtual Methods" from SfxPoolItem
virtual int operator==( const SfxPoolItem& ) const;
virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
diff --git a/include/svx/ruler.hxx b/include/svx/ruler.hxx
index 55dea87..09d59f0 100644
--- a/include/svx/ruler.hxx
+++ b/include/svx/ruler.hxx
@@ -87,11 +87,11 @@ class SVX_DLLPUBLIC SvxRuler: public Ruler, public SfxListener
sal_uInt16 nTabBufSize;
long lDefTabDist;
long lTabPos;
- boost::scoped_array<RulerTab> mpTabs; // tab positions in pixel
- boost::scoped_array<RulerIndent> mpIndents; // paragraph margins in pixel
- boost::scoped_array<RulerBorder> mpBorders;
- sal_uInt16 nBorderCount;
- boost::scoped_array<RulerBorder> mpObjectBorders;
+
+ std::vector<RulerTab> mpTabs; // tab positions in pixel
+ std::vector<RulerIndent> mpIndents; // paragraph margins in pixel
+ std::vector<RulerBorder> mpBorders;
+ std::vector<RulerBorder> mpObjectBorders;
SfxBindings* pBindings;
long nDragOffset;
@@ -167,7 +167,7 @@ class SVX_DLLPUBLIC SvxRuler: public Ruler, public SfxListener
long GetRightIndent() const;
long GetLogicRightIndent() const;
- inline long GetLeftFrameMargin() const;
+ long GetLeftFrameMargin() const;
long GetRightFrameMargin() const;
void CalcMinMax();
diff --git a/svx/source/dialog/svxruler.cxx b/svx/source/dialog/svxruler.cxx
index 2542ac5..1d41531 100644
--- a/svx/source/dialog/svxruler.cxx
+++ b/svx/source/dialog/svxruler.cxx
@@ -220,8 +220,7 @@ SvxRuler::SvxRuler(
nTabBufSize(0),
lDefTabDist(50),
lTabPos(-1),
- mpBorders(new RulerBorder[1]), // due to one column tables
- nBorderCount(0),
+ mpBorders(1), // due to one column tables
pBindings(&rBindings),
nDragOffset(0),
nMaxLeft(0),
@@ -272,16 +271,19 @@ SvxRuler::SvxRuler(
else
pCtrlItem[i++] = new SvxRulerItem(SID_ATTR_PARA_LRSPACE_VERTICAL, *this, rBindings);
- mpIndents.reset(new RulerIndent[5 + INDENT_GAP]);
- memset(mpIndents.get(), 0, sizeof(RulerIndent) * (3 + INDENT_GAP));
+ mpIndents.resize(5 + INDENT_GAP);
+
+ for(sal_uInt32 nIn = 0; nIn < mpIndents.size(); nIn++)
+ {
+ mpIndents[nIn].nPos = 0;
+ mpIndents[nIn].nStyle = RULER_STYLE_DONTKNOW;
+ }
+
mpIndents[0].nStyle = RULER_STYLE_DONTKNOW;
mpIndents[1].nStyle = RULER_STYLE_DONTKNOW;
mpIndents[INDENT_FIRST_LINE].nStyle = RULER_INDENT_TOP;
mpIndents[INDENT_LEFT_MARGIN].nStyle = RULER_INDENT_BOTTOM;
mpIndents[INDENT_RIGHT_MARGIN].nStyle = RULER_INDENT_BOTTOM;
-
- for(sal_uInt16 nIn = 0; nIn < 7; nIn++)
- mpIndents[nIn].nPos = 0;
}
if( (nFlags & SVXRULER_SUPPORT_BORDERS) == SVXRULER_SUPPORT_BORDERS )
@@ -295,9 +297,7 @@ SvxRuler::SvxRuler(
if( (nFlags & SVXRULER_SUPPORT_OBJECT) == SVXRULER_SUPPORT_OBJECT )
{
pCtrlItem[i++] = new SvxRulerItem(SID_RULER_OBJECT, *this, rBindings );
- mpObjectBorders.reset(new RulerBorder[OBJECT_BORDER_COUNT]);
- size_t nSize = sizeof( RulerBorder ) * OBJECT_BORDER_COUNT;
- memset(mpObjectBorders.get(), 0, nSize);
+ mpObjectBorders.resize(OBJECT_BORDER_COUNT);
for(sal_uInt16 nBorder = 0; nBorder < OBJECT_BORDER_COUNT; ++nBorder)
{
mpObjectBorders[nBorder].nPos = 0;
@@ -759,11 +759,7 @@ void SvxRuler::UpdateColumns()
/* Update column view */
if(mpColumnItem.get() && mpColumnItem->Count() > 1)
{
- if( nBorderCount < mpColumnItem->Count())
- {
- nBorderCount = mpColumnItem->Count();
- mpBorders.reset(new RulerBorder[nBorderCount]);
- }
+ mpBorders.resize(mpColumnItem->Count());
sal_uInt16 nStyleFlags = RULER_BORDER_VARIABLE;
@@ -805,7 +801,7 @@ void SvxRuler::UpdateColumns()
mpBorders[i].nMinPos = ConvertPosPixel(mpColumnItem->At(i).nEndMin + lAppNullOffset);
mpBorders[i].nMaxPos = ConvertPosPixel(mpColumnItem->At(i).nEndMax + lAppNullOffset);
}
- SetBorders(mpColumnItem->Count() - 1, mpBorders.get());
+ SetBorders(mpColumnItem->Count() - 1, &mpBorders[0]);
}
else
{
@@ -818,7 +814,7 @@ void SvxRuler::UpdateObject()
/* Update view of object representation */
if(mpObjectItem.get())
{
- DBG_ASSERT(mpObjectBorders.get(), "no Buffer");
+ DBG_ASSERT(!mpObjectBorders.empty(), "no Buffer");
// !! to the page margin
long nMargin = mpLRSpaceItem.get() ? mpLRSpaceItem->GetLeft() : 0;
mpObjectBorders[0].nPos =
@@ -834,7 +830,7 @@ void SvxRuler::UpdateObject()
ConvertPosPixel(mpObjectItem->GetEndY() - nMargin + lAppNullOffset);
const sal_uInt16 nOffset = GetObjectBordersOff(0);
- SetBorders(2, mpObjectBorders.get() + nOffset);
+ SetBorders(2, &mpObjectBorders[0] + nOffset);
}
else
{
@@ -890,11 +886,11 @@ void SvxRuler::UpdatePara()
else
mpIndents[INDENT_FIRST_LINE].nStyle &= ~RULER_STYLE_INVISIBLE;
- SetIndents(INDENT_COUNT, mpIndents.get() + INDENT_GAP);
+ SetIndents(INDENT_COUNT, &mpIndents[0] + INDENT_GAP);
}
else
{
- if(mpIndents.get())
+ if(!mpIndents.empty())
{
mpIndents[INDENT_FIRST_LINE].nPos = 0;
mpIndents[INDENT_LEFT_MARGIN].nPos = 0;
@@ -1054,7 +1050,7 @@ void SvxRuler::UpdateTabs()
const long lParaIndent = nLeftFrameMargin + nParaItemTxtLeft;
const long lLastTab = mpTabStopItem->Count()
- ? ConvertHPosPixel((*mpTabStopItem.get())[mpTabStopItem->Count()-1].GetTabPos())
+ ? ConvertHPosPixel(mpTabStopItem->At(mpTabStopItem->Count() - 1).GetTabPos())
: 0;
const long lPosPixel = ConvertHPosPixel(lParaIndent) + lLastTab;
const long lRightIndent = ConvertHPosPixel(nRightFrameMargin - mpParaItem->GetRight());
@@ -1072,7 +1068,7 @@ void SvxRuler::UpdateTabs()
{
// 10 (GAP) in stock
nTabBufSize = mpTabStopItem->Count() + TAB_GAP + nDefTabBuf + GAP;
- mpTabs.reset(new RulerTab[nTabBufSize]);
+ mpTabs.resize(nTabBufSize);
}
nTabCount = 0;
@@ -1084,17 +1080,21 @@ void SvxRuler::UpdateTabs()
for(j = 0; j < mpTabStopItem->Count(); ++j)
{
- const SvxTabStop* pTab = &(*mpTabStopItem.get())[j];
+ const SvxTabStop* pTab = &mpTabStopItem->At(j);
if (mpRulerImpl->bIsTabsRelativeToIndent)
- mpTabs[nTabCount + TAB_GAP].nPos =
- ConvertHPosPixel( lParaIndent + pTab->GetTabPos() + lAppNullOffset);
+ {
+ long nTabPosition = ConvertHPosPixel(lParaIndent + pTab->GetTabPos() + lAppNullOffset);
+ mpTabs[nTabCount + TAB_GAP].nPos = nTabPosition;
+ }
else
- mpTabs[nTabCount + TAB_GAP].nPos =
- ConvertHPosPixel( 0 + pTab->GetTabPos() + lAppNullOffset);
+ {
+ long nTabPosition = ConvertHPosPixel(0 + pTab->GetTabPos() + lAppNullOffset);
+ mpTabs[nTabCount + TAB_GAP].nPos = nTabPosition;
+ }
if(bRTL)
{
- mpTabs[nTabCount + TAB_GAP].nPos = lParaIndentPix + lRightPixMargin - mpTabs[nTabCount+TAB_GAP].nPos;
+ mpTabs[nTabCount + TAB_GAP].nPos = lParaIndentPix + lRightPixMargin - mpTabs[nTabCount + TAB_GAP].nPos;
}
mpTabs[nTabCount + TAB_GAP].nStyle = ToSvTab_Impl(pTab->GetAdjustment());
++nTabCount;
@@ -1119,7 +1119,7 @@ void SvxRuler::UpdateTabs()
% nDefTabDist );
}
- if(mpTabs[nTabCount+TAB_GAP].nPos <= lParaIndentPix)
+ if(mpTabs[nTabCount + TAB_GAP].nPos <= lParaIndentPix)
break;
mpTabs[nTabCount + TAB_GAP].nStyle = RULER_TAB_DEFAULT;
++nTabCount;
@@ -1135,12 +1135,10 @@ void SvxRuler::UpdateTabs()
//set the first default tab stop
if(mpRulerImpl->bIsTabsRelativeToIndent)
{
- mpTabs[nTabCount + TAB_GAP].nPos =
- (mpTabs[nTabCount].nPos + nDefTabDist);
+ mpTabs[nTabCount + TAB_GAP].nPos = (mpTabs[nTabCount].nPos + nDefTabDist);
mpTabs[nTabCount + TAB_GAP].nPos -=
- ((mpTabs[nTabCount + TAB_GAP].nPos - lParaIndentPix)
- % nDefTabDist );
+ (mpTabs[nTabCount + TAB_GAP].nPos - lParaIndentPix) % nDefTabDist;
aFirst = mpTabs[nTabCount + TAB_GAP].nPos;
}
else
@@ -1165,7 +1163,7 @@ void SvxRuler::UpdateTabs()
++nTabCount;
}
}
- SetTabs(nTabCount, mpTabs.get() + TAB_GAP);
+ SetTabs(nTabCount, &mpTabs[0] + TAB_GAP);
DBG_ASSERT(nTabCount + TAB_GAP <= nTabBufSize, "BufferSize too small");
}
else
@@ -1441,26 +1439,26 @@ void SvxRuler::AdjustMargin1(long lInputDiff)
{
// Right indent of the old position
mpIndents[INDENT_RIGHT_MARGIN].nPos -= lDiff;
- SetIndents(INDENT_COUNT, mpIndents.get() + INDENT_GAP);
+ SetIndents(INDENT_COUNT, &mpIndents[0] + INDENT_GAP);
}
if(mpObjectItem.get())
{
mpObjectBorders[GetObjectBordersOff(0)].nPos -= lDiff;
mpObjectBorders[GetObjectBordersOff(1)].nPos -= lDiff;
- SetBorders(2, mpObjectBorders.get() + GetObjectBordersOff(0));
+ SetBorders(2, &mpObjectBorders[0] + GetObjectBordersOff(0));
}
if(mpColumnItem.get())
{
for(sal_uInt16 i = 0; i < mpColumnItem->Count()-1; ++i)
mpBorders[i].nPos -= lDiff;
- SetBorders(mpColumnItem->Count()-1, mpBorders.get());
+ SetBorders(mpColumnItem->Count()-1, &mpBorders[0]);
if(mpColumnItem->IsFirstAct())
{
// Right indent of the old position
if(mpParaItem.get())
{
mpIndents[INDENT_RIGHT_MARGIN].nPos -= lDiff;
- SetIndents(INDENT_COUNT, mpIndents.get() + INDENT_GAP);
+ SetIndents(INDENT_COUNT, &mpIndents[0] + INDENT_GAP);
}
}
else
@@ -1470,14 +1468,14 @@ void SvxRuler::AdjustMargin1(long lInputDiff)
mpIndents[INDENT_FIRST_LINE].nPos -= lDiff;
mpIndents[INDENT_LEFT_MARGIN].nPos -= lDiff;
mpIndents[INDENT_RIGHT_MARGIN].nPos -= lDiff;
- SetIndents(INDENT_COUNT, mpIndents.get() + INDENT_GAP);
+ SetIndents(INDENT_COUNT, &mpIndents[0] + INDENT_GAP);
}
}
if(mpTabStopItem.get() && (nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL)
&&!IsActFirstColumn())
{
- ModifyTabs_Impl(nTabCount+TAB_GAP, mpTabs.get(), - lDiff);
- SetTabs(nTabCount, mpTabs.get() + TAB_GAP);
+ ModifyTabs_Impl(nTabCount + TAB_GAP, &mpTabs[0], -lDiff);
+ SetTabs(nTabCount, &mpTabs[0] + TAB_GAP);
}
}
}
@@ -1494,14 +1492,14 @@ void SvxRuler::AdjustMargin1(long lInputDiff)
// Left indent of the old position
mpIndents[INDENT_FIRST_LINE].nPos += lDiff;
mpIndents[INDENT_LEFT_MARGIN].nPos += lDiff;
- SetIndents(INDENT_COUNT, mpIndents.get() + INDENT_GAP);
+ SetIndents(INDENT_COUNT, &mpIndents[0] + INDENT_GAP);
}
if (mpColumnItem.get())
{
for(sal_uInt16 i = 0; i < mpColumnItem->Count() - 1; ++i)
mpBorders[i].nPos += lDiff;
- SetBorders(mpColumnItem->Count() - 1, mpBorders.get());
+ SetBorders(mpColumnItem->Count() - 1, &mpBorders[0]);
if (mpColumnItem->IsFirstAct())
{
// Left indent of the old position
@@ -1509,7 +1507,7 @@ void SvxRuler::AdjustMargin1(long lInputDiff)
{
mpIndents[INDENT_FIRST_LINE].nPos += lDiff;
mpIndents[INDENT_LEFT_MARGIN].nPos += lDiff;
- SetIndents(INDENT_COUNT, mpIndents.get() + INDENT_GAP);
+ SetIndents(INDENT_COUNT, &mpIndents[0] + INDENT_GAP);
}
}
else
@@ -1519,14 +1517,14 @@ void SvxRuler::AdjustMargin1(long lInputDiff)
mpIndents[INDENT_FIRST_LINE].nPos += lDiff;
mpIndents[INDENT_LEFT_MARGIN].nPos += lDiff;
mpIndents[INDENT_RIGHT_MARGIN].nPos += lDiff;
- SetIndents(INDENT_COUNT, mpIndents.get() + INDENT_GAP);
+ SetIndents(INDENT_COUNT, &mpIndents[0] + INDENT_GAP);
}
}
}
if(mpTabStopItem.get())
{
- ModifyTabs_Impl(nTabCount+TAB_GAP, mpTabs.get(), lDiff);
- SetTabs(nTabCount, mpTabs.get() + TAB_GAP);
+ ModifyTabs_Impl(nTabCount + TAB_GAP, &mpTabs[0], lDiff);
+ SetTabs(nTabCount, &mpTabs[0] + TAB_GAP);
}
}
}
@@ -1563,7 +1561,7 @@ void SvxRuler::DragMargin2()
if((!mpColumnItem.get() || IsActLastColumn()) && mpParaItem.get())
{
mpIndents[INDENT_FIRST_LINE].nPos += lDiff;
- SetIndents(INDENT_COUNT, mpIndents.get() + INDENT_GAP);
+ SetIndents(INDENT_COUNT, &mpIndents[0] + INDENT_GAP);
}
DrawLine_Impl(lTabPos, ( TAB_FLAG && NEG_FLAG ) ? 5 : 7, bHorz);
@@ -1596,7 +1594,7 @@ void SvxRuler::DragIndents()
mpIndents[nIndex].nPos = aDragPosition;
- SetIndents(INDENT_COUNT, mpIndents.get() + INDENT_GAP);
+ SetIndents(INDENT_COUNT, &mpIndents[0] + INDENT_GAP);
DrawLine_Impl(lTabPos, 1, bHorz);
}
@@ -1695,7 +1693,7 @@ void SvxRuler::DragTabs()
long nDelta = mpRulerImpl->nTotalDist * mpRulerImpl->pPercBuf[i];
nDelta /= 1000;
mpTabs[i].nPos = mpTabs[nIdx].nPos + nDelta;
- if(mpTabs[i].nPos+GetNullOffset() > nMaxRight)
+ if(mpTabs[i].nPos + GetNullOffset() > nMaxRight)
mpTabs[i].nStyle |= RULER_STYLE_INVISIBLE;
else
mpTabs[i].nStyle &= ~RULER_STYLE_INVISIBLE;
@@ -1710,7 +1708,7 @@ void SvxRuler::DragTabs()
mpTabs[nIdx].nStyle |= RULER_STYLE_INVISIBLE;
else
mpTabs[nIdx].nStyle &= ~RULER_STYLE_INVISIBLE;
- SetTabs(nTabCount, mpTabs.get() + TAB_GAP);
+ SetTabs(nTabCount, &mpTabs[0] + TAB_GAP);
}
void SvxRuler::SetActive(sal_Bool bOn)
@@ -1752,18 +1750,18 @@ void SvxRuler::UpdateParaContents_Impl(
{
mpIndents[INDENT_FIRST_LINE].nPos += lDifference;
mpIndents[INDENT_LEFT_MARGIN].nPos += lDifference;
- if (mpTabs.get())
+ if (!mpTabs.empty())
{
for(sal_uInt16 i = 0; i < nTabCount+TAB_GAP; ++i)
{
mpTabs[i].nPos += lDifference;
}
- SetTabs(nTabCount, mpTabs.get() + TAB_GAP);
+ SetTabs(nTabCount, &mpTabs[0] + TAB_GAP);
}
break;
}
}
- SetIndents(INDENT_COUNT, mpIndents.get() + INDENT_GAP);
+ SetIndents(INDENT_COUNT, &mpIndents[0] + INDENT_GAP);
}
void SvxRuler::DragBorders()
@@ -1802,7 +1800,7 @@ ADD_DEBUG_TEXT("lLastLMargin: ", OUString::number(mpRulerImpl->lLastLMargin))
if(nDragType & DRAG_OBJECT_SIZE_LINEAR)
{
long nRight = GetMargin2() - lMinFrame; // Right limiters
- for(int i = nBorderCount - 2; i >= nIndex; --i)
+ for(int i = mpBorders.size() - 2; i >= nIndex; --i)
{
long l = mpBorders[i].nPos;
mpBorders[i].nPos += lDiff;
@@ -1826,7 +1824,7 @@ ADD_DEBUG_TEXT("lLastLMargin: ", OUString::number(mpRulerImpl->lLastLMargin))
{
int nLimit;
long lLeft;
- int nStartLimit = nBorderCount-2;
+ int nStartLimit = mpBorders.size() - 2;
switch(GetDragType())
{
default: ;//prevent warning
@@ -1865,7 +1863,7 @@ ADD_DEBUG_TEXT("lLastLMargin: ", OUString::number(mpRulerImpl->lLastLMargin))
case RULER_TYPE_MARGIN2:
nLimit = 0;
lLeft= 0;
- nStartLimit = nBorderCount - 2;
+ nStartLimit = mpBorders.size() - 2;
mpRulerImpl->nTotalDist += lDiff;
break;
}
@@ -1941,7 +1939,7 @@ ADD_DEBUG_TEXT("lLastLMargin: ", OUString::number(mpRulerImpl->lLastLMargin))
else
{
//otherwise the right borders are moved
- for(int i = nBorderCount-2; i >= nLimit; --i)
+ for(int i = mpBorders.size() - 2; i >= nLimit; --i)
{
mpBorders[i].nPos += lDiff;
}
@@ -1970,7 +1968,7 @@ ADD_DEBUG_TEXT("lLastLMargin: ", OUString::number(mpRulerImpl->lLastLMargin))
if(!bRightIndentsCorrected &&
GetActRightColumn() == nIndex &&
nDragSize != RULER_DRAGSIZE_2 &&
- mpIndents.get() &&
+ !mpIndents.empty() &&
!mpRulerImpl->bIsTableRows)
{
UpdateParaContents_Impl(lDiff, MOVE_RIGHT);
@@ -1978,11 +1976,11 @@ ADD_DEBUG_TEXT("lLastLMargin: ", OUString::number(mpRulerImpl->lLastLMargin))
else if(!bLeftIndentsCorrected &&
GetActLeftColumn() == nIndex &&
nDragSize != RULER_DRAGSIZE_1 &&
- mpIndents.get())
+ !mpIndents.empty())
{
UpdateParaContents_Impl(lDiff, MOVE_LEFT);
}
- SetBorders(mpColumnItem->Count() - 1, mpBorders.get());
+ SetBorders(mpColumnItem->Count() - 1, &mpBorders[0]);
}
void SvxRuler::DragObjectBorder()
@@ -1994,7 +1992,7 @@ void SvxRuler::DragObjectBorder()
const sal_uInt16 nIdx = GetDragAryPos();
mpObjectBorders[GetObjectBordersOff(nIdx)].nPos = lPosition;
- SetBorders(2, mpObjectBorders.get() + GetObjectBordersOff(0));
+ SetBorders(2, &mpObjectBorders[0] + GetObjectBordersOff(0));
DrawLine_Impl(lTabPos, 7, bHorz);
}
@@ -2207,15 +2205,14 @@ void SvxRuler::ApplyTabs()
sal_uInt16 j;
for(j = 0; j < nCoreIdx; ++j)
{
- pItem->Insert((*mpTabStopItem.get())[j]);
+ pItem->Insert(mpTabStopItem->At(j));
}
for(; j < mpTabStopItem->Count(); ++j)
{
- SvxTabStop aTabStop = (*mpTabStopItem.get())[j];
+ SvxTabStop aTabStop = mpTabStopItem->At(j);
aTabStop.GetTabPos() = PixelHAdjust(
- ConvertHPosLogic(mpTabs[j + TAB_GAP].nPos -
- GetLeftIndent()) -
- lAppNullOffset,
+ ConvertHPosLogic(
+ mpTabs[j + TAB_GAP].nPos - GetLeftIndent()) - lAppNullOffset,
aTabStop.GetTabPos());
pItem->Insert(aTabStop);
}
@@ -2225,10 +2222,12 @@ void SvxRuler::ApplyTabs()
return;
else
{
- SvxTabStop aTabStop = (*mpTabStopItem.get())[nCoreIdx];
- if(mpRulerImpl->lMaxRightLogic!=-1&&
- mpTabs[nCoreIdx+TAB_GAP].nPos + Ruler::GetNullOffset() == nMaxRight)
- aTabStop.GetTabPos() = mpRulerImpl->lMaxRightLogic-lLogicNullOffset;
+ SvxTabStop aTabStop = mpTabStopItem->At(nCoreIdx);
+ if( mpRulerImpl->lMaxRightLogic != -1 &&
+ mpTabs[nCoreIdx + TAB_GAP].nPos + Ruler::GetNullOffset() == nMaxRight )
+ {
+ aTabStop.GetTabPos() = mpRulerImpl->lMaxRightLogic - lLogicNullOffset;
+ }
else
{
if(bRTL)
@@ -2238,20 +2237,17 @@ void SvxRuler::ApplyTabs()
GetLeftIndent() :
ConvertHPosPixel( GetRightFrameMargin() + lAppNullOffset );
- aTabStop.GetTabPos() = PixelHAdjust(
- ConvertHPosLogic( nTmpLeftIndent - mpTabs[nCoreIdx+TAB_GAP].nPos) - lAppNullOffset,
- aTabStop.GetTabPos());
+ long nNewPosition = ConvertHPosLogic(nTmpLeftIndent - mpTabs[nCoreIdx + TAB_GAP].nPos);
+ aTabStop.GetTabPos() = PixelHAdjust(nNewPosition - lAppNullOffset, aTabStop.GetTabPos());
}
else
{
//#i24363# tab stops relative to indent
const long nTmpLeftIndent = mpRulerImpl->bIsTabsRelativeToIndent ?
- GetLeftIndent() :
- 0;
+ GetLeftIndent() : 0;
- aTabStop.GetTabPos() = PixelHAdjust(
- ConvertHPosLogic( mpTabs[nCoreIdx+TAB_GAP].nPos - nTmpLeftIndent ) - lAppNullOffset,
- aTabStop.GetTabPos() );
+ long nNewPosition = ConvertHPosLogic(mpTabs[nCoreIdx + TAB_GAP].nPos - nTmpLeftIndent);
+ aTabStop.GetTabPos() = PixelHAdjust(nNewPosition - lAppNullOffset, aTabStop.GetTabPos());
}
}
mpTabStopItem->Remove(nCoreIdx);
@@ -2922,8 +2918,8 @@ void SvxRuler::CalcMinMax()
}
else if(DRAG_OBJECT_SIZE_LINEAR & nDragType)
{
- nMaxRight=lNullPix+GetMargin2()-GetMargin1()+
- (nBorderCount-nIdx-1)*lMinFrame;
+ nMaxRight = lNullPix + GetMargin2() - GetMargin1() +
+ (mpBorders.size() - nIdx - 1) * lMinFrame;
}
else
{
@@ -3317,13 +3313,13 @@ void SvxRuler::EndDrag()
case RULER_TYPE_INDENT: // Paragraph indents
if(lInitialDragPos != lPos)
ApplyIndents();
- SetIndents(INDENT_COUNT, mpIndents.get() + INDENT_GAP);
+ SetIndents(INDENT_COUNT, &mpIndents[0] + INDENT_GAP);
break;
case RULER_TYPE_TAB: // Tabs
{
ApplyTabs();
mpTabs[GetDragAryPos()].nStyle &= ~RULER_STYLE_INVISIBLE;
- SetTabs(nTabCount, mpTabs.get() + TAB_GAP);
+ SetTabs(nTabCount, &mpTabs[0] + TAB_GAP);
}
break;
default:
@@ -3395,8 +3391,8 @@ IMPL_LINK( SvxRuler, TabMenuSelect, Menu *, pMenu )
/* Handler of the tab menu for setting the type */
if(mpTabStopItem.get() && mpTabStopItem->Count() > mpRulerImpl->nIdx)
{
- SvxTabStop aTabStop = (*mpTabStopItem.get())[mpRulerImpl->nIdx];
- aTabStop.GetAdjustment() = ToAttrTab_Impl(pMenu->GetCurItemId()-1);
+ SvxTabStop aTabStop = mpTabStopItem->At(mpRulerImpl->nIdx);
+ aTabStop.GetAdjustment() = ToAttrTab_Impl(pMenu->GetCurItemId() - 1);
mpTabStopItem->Remove(mpRulerImpl->nIdx);
mpTabStopItem->Insert(aTabStop);
sal_uInt16 nTabStopId = bHorz ? SID_ATTR_TABSTOP : SID_ATTR_TABSTOP_VERTICAL;
@@ -3414,7 +3410,7 @@ void SvxRuler::Command( const CommandEvent& rCommandEvent )
{
CancelDrag();
sal_Bool bRTL = mpRulerImpl->pTextRTLItem && mpRulerImpl->pTextRTLItem->GetValue();
- if ( mpTabs.get() &&
+ if ( !mpTabs.empty() &&
RULER_TYPE_TAB ==
GetType( rCommandEvent.GetMousePosPixel(), &mpRulerImpl->nIdx ) &&
mpTabs[mpRulerImpl->nIdx + TAB_GAP].nStyle < RULER_TAB_DEFAULT )
@@ -3568,13 +3564,13 @@ long SvxRuler::CalcPropMaxRight(sal_uInt16 nCol) const
lFences = mpBorders[nCol].nWidth;
}
- for(sal_uInt16 i = nStart; i < nBorderCount - 1; ++i)
+ for(sal_uInt16 i = nStart; i < mpBorders.size() - 1; ++i)
{
long lWidth = mpBorders[i].nPos - lOldPos;
lColumns += lWidth;
if(lWidth < lMinSpace)
lMinSpace = lWidth;
- lOldPos = mpBorders[i].nPos+mpBorders[i].nWidth;
+ lOldPos = mpBorders[i].nPos + mpBorders[i].nWidth;
lFences += mpBorders[i].nWidth;
}
long lWidth = GetMargin2() - lOldPos;
@@ -3596,7 +3592,7 @@ long SvxRuler::CalcPropMaxRight(sal_uInt16 nCol) const
lColumns = GetMargin2()-lOldPos;
nActCol = nCol;
lFences = 0;
- while(nActCol < nBorderCount || nActCol == USHRT_MAX)
+ while(nActCol < mpBorders.size() || nActCol == USHRT_MAX)
{
sal_uInt16 nRight;
if(nActCol == USHRT_MAX)
@@ -3638,7 +3634,7 @@ long SvxRuler::CalcPropMaxRight(sal_uInt16 nCol) const
if(mpColumnItem->IsTable())
{
sal_uInt16 nVisCols = 0;
- for(sal_uInt16 i = GetActRightColumn(sal_False, nCol); i<nBorderCount;)
+ for(sal_uInt16 i = GetActRightColumn(sal_False, nCol); i < mpBorders.size();)
{
if((*mpColumnItem.get())[i].bVisible)
nVisCols++;
@@ -3649,7 +3645,7 @@ long SvxRuler::CalcPropMaxRight(sal_uInt16 nCol) const
else
{
long lWidth = 0;
- for(sal_uInt16 i = nCol; i < nBorderCount - 1; i++)
+ for(sal_uInt16 i = nCol; i < mpBorders.size() - 1; i++)
{
lWidth += lMinFrame + mpBorders[i].nWidth;
}
commit b46079bb41591d9697339e8250d4ca7bf0930c0f
Author: Tomaž Vajngerl <quikee at gmail.com>
Date: Fri Sep 13 17:04:31 2013 +0200
Fix ruler margin dragging in vertical mode
Change-Id: I4727bbb304059859f3f5b4a96f834b41191c0bab
diff --git a/svx/source/dialog/svxruler.cxx b/svx/source/dialog/svxruler.cxx
index 79338c3..2542ac5 100644
--- a/svx/source/dialog/svxruler.cxx
+++ b/svx/source/dialog/svxruler.cxx
@@ -432,12 +432,12 @@ inline long SvxRuler::ConvertSizeLogic(long nVal) const
return bHorz? ConvertHSizeLogic(nVal): ConvertVSizeLogic(nVal);
}
-long SvxRuler::PixelHAdjust(long nVal, long /*nValOld*/) const
+long SvxRuler::PixelHAdjust(long nVal, long nValOld) const
{
- //if(ConvertHSizePixel(nVal) != ConvertHSizePixel(nValOld))
+ if(ConvertHSizePixel(nVal) != ConvertHSizePixel(nValOld))
return nVal;
- //else
- // return nValOld;
+ else
+ return nValOld;
}
long SvxRuler::PixelVAdjust(long nVal, long nValOld) const
@@ -477,49 +477,59 @@ void SvxRuler::UpdateFrame()
// if no initialization by default app behavior
const long nOld = lLogicNullOffset;
lLogicNullOffset = mpColumnItem.get() ? mpColumnItem->GetLeft(): mpLRSpaceItem->GetLeft();
+
if(bAppSetNullOffset)
lAppNullOffset += lLogicNullOffset - nOld;
+
if(!bAppSetNullOffset || lAppNullOffset == LONG_MAX)
{
Ruler::SetNullOffset(ConvertHPosPixel(lLogicNullOffset));
- SetMargin1( 0, nMarginStyle );
+ SetMargin1(0, nMarginStyle);
lAppNullOffset = 0;
}
else
- SetMargin1( ConvertHPosPixel( lAppNullOffset ), nMarginStyle );
+ {
+ SetMargin1(ConvertHPosPixel(lAppNullOffset), nMarginStyle);
+ }
+
long lRight = 0;
- // evaluate the table right edge of the table
+
+ // evaluate the table right edge of the table
if(mpColumnItem.get() && mpColumnItem->IsTable())
lRight = mpColumnItem->GetRight();
else
lRight = mpLRSpaceItem->GetRight();
- sal_uIntPtr aWidth=
- ConvertHPosPixel(mpPagePosItem->GetWidth() - lRight -
- lLogicNullOffset + lAppNullOffset);
- SetMargin2( aWidth, nMarginStyle );
+ long aWidth = mpPagePosItem->GetWidth() - lRight - lLogicNullOffset + lAppNullOffset;
+ long aWidthPixel = ConvertHPosPixel(aWidth);
+
+ SetMargin2(aWidthPixel, nMarginStyle);
}
else if(mpULSpaceItem.get() && mpPagePosItem.get())
{
// relative the upper edge of the surrounding frame
const long nOld = lLogicNullOffset;
lLogicNullOffset = mpColumnItem.get() ? mpColumnItem->GetLeft() : mpULSpaceItem->GetUpper();
+
if(bAppSetNullOffset)
lAppNullOffset += lLogicNullOffset - nOld;
+
if(!bAppSetNullOffset || lAppNullOffset == LONG_MAX)
{
Ruler::SetNullOffset(ConvertVPosPixel(lLogicNullOffset));
lAppNullOffset = 0;
- SetMargin1( 0, nMarginStyle );
+ SetMargin1(0, nMarginStyle);
}
else
- SetMargin1( ConvertVPosPixel( lAppNullOffset ),nMarginStyle );
+ {
+ SetMargin1(ConvertVPosPixel(lAppNullOffset), nMarginStyle);
+ }
long lLower = mpColumnItem.get() ? mpColumnItem->GetRight() : mpULSpaceItem->GetLower();
+ long nMargin2 = mpPagePosItem->GetHeight() - lLower - lLogicNullOffset + lAppNullOffset;
+ long nMargin2Pixel = ConvertVPosPixel(nMargin2);
- SetMargin2(
- ConvertVPosPixel(mpPagePosItem->GetHeight() - lLower - lLogicNullOffset + lAppNullOffset),
- nMarginStyle);
+ SetMargin2(nMargin2Pixel, nMarginStyle);
}
else
{
@@ -754,10 +764,13 @@ void SvxRuler::UpdateColumns()
nBorderCount = mpColumnItem->Count();
mpBorders.reset(new RulerBorder[nBorderCount]);
}
+
sal_uInt16 nStyleFlags = RULER_BORDER_VARIABLE;
+
sal_Bool bProtectColumns =
- mpRulerImpl->aProtectItem.IsSizeProtected() ||
- mpRulerImpl->aProtectItem.IsPosProtected();
+ mpRulerImpl->aProtectItem.IsSizeProtected() ||
+ mpRulerImpl->aProtectItem.IsPosProtected();
+
if( !bProtectColumns )
nStyleFlags |= RULER_BORDER_MOVEABLE;
@@ -767,15 +780,18 @@ void SvxRuler::UpdateColumns()
nStyleFlags |= RULER_BORDER_SIZEABLE;
sal_uInt16 nBorders = mpColumnItem->Count();
+
if(!mpRulerImpl->bIsTableRows)
--nBorders;
+
for(sal_uInt16 i = 0; i < nBorders; ++i)
{
mpBorders[i].nStyle = nStyleFlags;
- if(!(*mpColumnItem.get())[i].bVisible)
+ if(!mpColumnItem->At(i).bVisible)
mpBorders[i].nStyle |= RULER_STYLE_INVISIBLE;
- mpBorders[i].nPos =
- ConvertPosPixel((*mpColumnItem.get())[i].nEnd + lAppNullOffset);
+
+ mpBorders[i].nPos = ConvertPosPixel(mpColumnItem->At(i).nEnd + lAppNullOffset);
+
if(mpColumnItem->Count() == i + 1)
{
//with table rows the end of the table is contained in the
@@ -784,14 +800,10 @@ void SvxRuler::UpdateColumns()
}
else
{
- mpBorders[i].nWidth =
- ConvertSizePixel((*mpColumnItem.get())[i+1].nStart -
- (*mpColumnItem.get())[i].nEnd);
+ mpBorders[i].nWidth = ConvertSizePixel(mpColumnItem->At(i + 1).nStart - mpColumnItem->At(i).nEnd);
}
- mpBorders[i].nMinPos =
- ConvertPosPixel((*mpColumnItem.get())[i].nEndMin + lAppNullOffset);
- mpBorders[i].nMaxPos =
- ConvertPosPixel((*mpColumnItem.get())[i].nEndMax + lAppNullOffset);
+ mpBorders[i].nMinPos = ConvertPosPixel(mpColumnItem->At(i).nEndMin + lAppNullOffset);
+ mpBorders[i].nMaxPos = ConvertPosPixel(mpColumnItem->At(i).nEndMax + lAppNullOffset);
}
SetBorders(mpColumnItem->Count() - 1, mpBorders.get());
}
@@ -1724,26 +1736,27 @@ void SvxRuler::SetActive(sal_Bool bOn)
}
void SvxRuler::UpdateParaContents_Impl(
- long l, // Difference
+ long lDifference,
UpdateType eType) // Art (all, left or right)
{
/* Helper function; carry Tabs and Paragraph Margins */
- switch(eType) {
- case MOVE_RIGHT:
- mpIndents[INDENT_RIGHT_MARGIN].nPos += l;
- break;
- case MOVE_ALL:
- mpIndents[INDENT_RIGHT_MARGIN].nPos += l;
- // no break
- case MOVE_LEFT:
+ switch(eType)
+ {
+ case MOVE_RIGHT:
+ mpIndents[INDENT_RIGHT_MARGIN].nPos += lDifference;
+ break;
+ case MOVE_ALL:
+ mpIndents[INDENT_RIGHT_MARGIN].nPos += lDifference;
+ // no break
+ case MOVE_LEFT:
{
- mpIndents[INDENT_FIRST_LINE].nPos += l;
- mpIndents[INDENT_LEFT_MARGIN].nPos += l;
+ mpIndents[INDENT_FIRST_LINE].nPos += lDifference;
+ mpIndents[INDENT_LEFT_MARGIN].nPos += lDifference;
if (mpTabs.get())
{
for(sal_uInt16 i = 0; i < nTabCount+TAB_GAP; ++i)
{
- mpTabs[i].nPos += l;
+ mpTabs[i].nPos += lDifference;
}
SetTabs(nTabCount, mpTabs.get() + TAB_GAP);
}
diff --git a/sw/source/ui/uiview/viewtab.cxx b/sw/source/ui/uiview/viewtab.cxx
index 2be6825..e5c4f30 100644
--- a/sw/source/ui/uiview/viewtab.cxx
+++ b/sw/source/ui/uiview/viewtab.cxx
@@ -1610,19 +1610,38 @@ void SwView::StateTabWin(SfxItemSet& rSet)
const SwRect aPrtRect = rSh.GetAnyCurRect(RECT_PAGE_PRT, pPt);
const SvxBoxItem& rBox = (const SvxBoxItem&)rMaster.GetFmtAttr(RES_BOX);
long nDist = rBox.GetDistance();
- ::lcl_FillSvxColumn(aCol,
+
+ lcl_FillSvxColumn(
+ aCol,
sal_uInt16(bVerticalWriting ? aPrtRect.Height() : aPrtRect.Width() ),
aColItem, nDist);
if(bBrowse)
{
- aColItem.SetLeft((sal_uInt16)rPagePrtRect.Left());
- aColItem.SetRight(sal_uInt16(nPageWidth - rPagePrtRect.Right()));
+ if (bVerticalWriting)
+ {
+ aColItem.SetLeft((sal_uInt16)rPagePrtRect.Top());
+ aColItem.SetRight(sal_uInt16(nPageHeight - rPagePrtRect.Bottom()));
+ }
+ else
+ {
+ aColItem.SetLeft((sal_uInt16)rPagePrtRect.Left());
+ aColItem.SetRight(sal_uInt16(nPageWidth - rPagePrtRect.Right()));
+ }
}
else
{
- aColItem.SetLeft (aPageLRSpace.GetLeft());
- aColItem.SetRight(aPageLRSpace.GetRight());
+ if (bVerticalWriting)
+ {
+ SvxULSpaceItem aUL( rDesc.GetMaster().GetULSpace() );
+ aColItem.SetLeft (aUL.GetUpper());
+ aColItem.SetRight(aUL.GetLower());
+ }
+ else
+ {
+ aColItem.SetLeft (aPageLRSpace.GetLeft());
+ aColItem.SetRight(aPageLRSpace.GetRight());
+ }
}
aColItem.SetOrtho(aColItem.CalcOrtho());
commit 9d4cbae332c3741b76cd80a4b31c6e2bed4ccb66
Author: Tomaž Vajngerl <quikee at gmail.com>
Date: Thu Sep 12 21:15:35 2013 +0200
ruler: Also show ticks below/above numbers in "negative" area
Change-Id: I70d9f0409962be607eddac1b308d8cc44d2a7b7f
diff --git a/svtools/source/control/ruler.cxx b/svtools/source/control/ruler.cxx
index 3593fe9..6a356c6 100644
--- a/svtools/source/control/ruler.cxx
+++ b/svtools/source/control/ruler.cxx
@@ -585,12 +585,15 @@ void Ruler::ImplDrawTicks( long nMin, long nMax, long nStart, long nTop, long nB
else
aNumString = OUString::number( nTick / aImplRulerUnitTab[mnUnitIndex].nTickUnit );
- ImplVDrawText( nStart + n, nCenter, aNumString, nMin, nMax );
- ImplVDrawText( nStart - n, nCenter, aNumString, nMin, nMax );
-
- ImplVDrawLine( nStart + n, nBottom, nStart + n, nBottom - 1 );
- ImplVDrawLine( nStart + n, nTop, nStart + n, nTop + 1 );
-
+ long nHorizontalLocation = nStart + n;
+ ImplVDrawText( nHorizontalLocation, nCenter, aNumString, nMin, nMax );
+ ImplVDrawLine( nHorizontalLocation, nBottom, nHorizontalLocation, nBottom - 1 );
+ ImplVDrawLine( nHorizontalLocation, nTop, nHorizontalLocation, nTop + 1 );
+
+ nHorizontalLocation = nStart - n;
+ ImplVDrawText( nHorizontalLocation, nCenter, aNumString, nMin, nMax );
+ ImplVDrawLine( nHorizontalLocation, nBottom, nHorizontalLocation, nBottom - 1 );
+ ImplVDrawLine( nHorizontalLocation, nTop, nHorizontalLocation, nTop + 1 );
}
// Tick/Tick2 - Output (Strokes)
else
commit 681f43274541fc4ab5e8c05739b0d74aa5f17be8
Author: Tomaž Vajngerl <quikee at gmail.com>
Date: Thu Sep 12 21:05:14 2013 +0200
ruler: RTL fixes for indents in tables and columns
Change-Id: I6c0a819e4a294fcf50c96a51bb9eea3ddef84c57
diff --git a/svx/source/dialog/svxruler.cxx b/svx/source/dialog/svxruler.cxx
index f4d0929..79338c3 100644
--- a/svx/source/dialog/svxruler.cxx
+++ b/svx/source/dialog/svxruler.cxx
@@ -1326,11 +1326,11 @@ inline long SvxRuler::GetRightMax() const
long SvxRuler::GetRightFrameMargin() const
{
/* Get right frame margin (in logical units) */
- if(mpColumnItem.get())
+ if (mpColumnItem.get())
{
- if(!IsActLastColumn( sal_True ))
+ if (!IsActLastColumn(true))
{
- return (*mpColumnItem.get())[GetActRightColumn( sal_True )].nEnd;
+ return mpColumnItem->At(GetActRightColumn(true)).nEnd;
}
}
@@ -1405,10 +1405,11 @@ void SvxRuler::DragMargin1()
AdjustMargin1(aDragPosition);
}
-void SvxRuler::AdjustMargin1(long lDiff)
+void SvxRuler::AdjustMargin1(long lInputDiff)
{
const long nOld = bAppSetNullOffset? GetMargin1(): GetNullOffset();
- const long lDragPos = lDiff;
+ const long lDragPos = lInputDiff;
+
sal_Bool bProtectColumns =
mpRulerImpl->aProtectItem.IsSizeProtected() ||
mpRulerImpl->aProtectItem.IsPosProtected();
@@ -1418,35 +1419,35 @@ void SvxRuler::AdjustMargin1(long lDiff)
if(!bAppSetNullOffset)
{
- long _lDiff = lDragPos;
- SetNullOffset(nOld + _lDiff);
+ long lDiff = lDragPos;
+ SetNullOffset(nOld + lDiff);
if (!mpColumnItem.get() || !(nDragType & DRAG_OBJECT_SIZE_LINEAR))
{
- SetMargin2( GetMargin2() - _lDiff, nMarginStyle );
+ SetMargin2( GetMargin2() - lDiff, nMarginStyle );
if (!mpColumnItem.get() && !mpObjectItem.get() && mpParaItem.get())
{
// Right indent of the old position
- mpIndents[INDENT_RIGHT_MARGIN].nPos -= _lDiff;
+ mpIndents[INDENT_RIGHT_MARGIN].nPos -= lDiff;
SetIndents(INDENT_COUNT, mpIndents.get() + INDENT_GAP);
}
if(mpObjectItem.get())
{
- mpObjectBorders[GetObjectBordersOff(0)].nPos -= _lDiff;
- mpObjectBorders[GetObjectBordersOff(1)].nPos -= _lDiff;
+ mpObjectBorders[GetObjectBordersOff(0)].nPos -= lDiff;
+ mpObjectBorders[GetObjectBordersOff(1)].nPos -= lDiff;
SetBorders(2, mpObjectBorders.get() + GetObjectBordersOff(0));
}
if(mpColumnItem.get())
{
for(sal_uInt16 i = 0; i < mpColumnItem->Count()-1; ++i)
- mpBorders[i].nPos -= _lDiff;
+ mpBorders[i].nPos -= lDiff;
SetBorders(mpColumnItem->Count()-1, mpBorders.get());
if(mpColumnItem->IsFirstAct())
{
// Right indent of the old position
if(mpParaItem.get())
{
- mpIndents[INDENT_RIGHT_MARGIN].nPos -= _lDiff;
+ mpIndents[INDENT_RIGHT_MARGIN].nPos -= lDiff;
SetIndents(INDENT_COUNT, mpIndents.get() + INDENT_GAP);
}
}
@@ -1454,16 +1455,16 @@ void SvxRuler::AdjustMargin1(long lDiff)
{
if(mpParaItem.get())
{
- mpIndents[INDENT_FIRST_LINE].nPos -= _lDiff;
- mpIndents[INDENT_LEFT_MARGIN].nPos -= _lDiff;
- mpIndents[INDENT_RIGHT_MARGIN].nPos -= _lDiff;
+ mpIndents[INDENT_FIRST_LINE].nPos -= lDiff;
+ mpIndents[INDENT_LEFT_MARGIN].nPos -= lDiff;
+ mpIndents[INDENT_RIGHT_MARGIN].nPos -= lDiff;
SetIndents(INDENT_COUNT, mpIndents.get() + INDENT_GAP);
}
}
if(mpTabStopItem.get() && (nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL)
&&!IsActFirstColumn())
{
- ModifyTabs_Impl(nTabCount+TAB_GAP, mpTabs.get(), - _lDiff);
+ ModifyTabs_Impl(nTabCount+TAB_GAP, mpTabs.get(), - lDiff);
SetTabs(nTabCount, mpTabs.get() + TAB_GAP);
}
}
@@ -1471,31 +1472,31 @@ void SvxRuler::AdjustMargin1(long lDiff)
}
else
{
- long _lDiff = lDragPos - nOld;
- SetMargin1(nOld + _lDiff, nMarginStyle );
+ long lDiff = lDragPos - nOld;
+ SetMargin1(nOld + lDiff, nMarginStyle);
if (!mpColumnItem.get() || !(nDragType & (DRAG_OBJECT_SIZE_LINEAR | DRAG_OBJECT_SIZE_PROPORTIONAL)))
{
if (!mpColumnItem.get() && !mpObjectItem.get() && mpParaItem.get())
{
// Left indent of the old position
- mpIndents[INDENT_FIRST_LINE].nPos += _lDiff;
- mpIndents[INDENT_LEFT_MARGIN].nPos += _lDiff;
+ mpIndents[INDENT_FIRST_LINE].nPos += lDiff;
+ mpIndents[INDENT_LEFT_MARGIN].nPos += lDiff;
SetIndents(INDENT_COUNT, mpIndents.get() + INDENT_GAP);
}
if (mpColumnItem.get())
{
- for(sal_uInt16 i = 0; i < mpColumnItem->Count()-1; ++i)
- mpBorders[i].nPos += _lDiff;
- SetBorders(mpColumnItem->Count()-1, mpBorders.get());
+ for(sal_uInt16 i = 0; i < mpColumnItem->Count() - 1; ++i)
+ mpBorders[i].nPos += lDiff;
+ SetBorders(mpColumnItem->Count() - 1, mpBorders.get());
if (mpColumnItem->IsFirstAct())
{
// Left indent of the old position
if(mpParaItem.get())
{
- mpIndents[INDENT_FIRST_LINE].nPos += _lDiff;
- mpIndents[INDENT_LEFT_MARGIN].nPos += _lDiff;
+ mpIndents[INDENT_FIRST_LINE].nPos += lDiff;
+ mpIndents[INDENT_LEFT_MARGIN].nPos += lDiff;
SetIndents(INDENT_COUNT, mpIndents.get() + INDENT_GAP);
}
}
@@ -1503,16 +1504,16 @@ void SvxRuler::AdjustMargin1(long lDiff)
{
if(mpParaItem.get())
{
- mpIndents[INDENT_FIRST_LINE].nPos += _lDiff;
- mpIndents[INDENT_LEFT_MARGIN].nPos += _lDiff;
- mpIndents[INDENT_RIGHT_MARGIN].nPos += _lDiff;
+ mpIndents[INDENT_FIRST_LINE].nPos += lDiff;
+ mpIndents[INDENT_LEFT_MARGIN].nPos += lDiff;
+ mpIndents[INDENT_RIGHT_MARGIN].nPos += lDiff;
SetIndents(INDENT_COUNT, mpIndents.get() + INDENT_GAP);
}
}
}
if(mpTabStopItem.get())
{
- ModifyTabs_Impl(nTabCount+TAB_GAP, mpTabs.get(), _lDiff);
+ ModifyTabs_Impl(nTabCount+TAB_GAP, mpTabs.get(), lDiff);
SetTabs(nTabCount, mpTabs.get() + TAB_GAP);
}
}
@@ -1562,10 +1563,12 @@ void SvxRuler::DragIndents()
long aDragPosition = NEG_FLAG ? GetDragPos() : GetCorrectedDragPos();
const sal_uInt16 nIndex = GetDragAryPos() + INDENT_GAP;
+ bool bRTL = mpRulerImpl->pTextRTLItem && mpRulerImpl->pTextRTLItem->GetValue();
+
if(nIndex == INDENT_RIGHT_MARGIN)
- aDragPosition = MakePositionSticky(aDragPosition, GetRightFrameMargin());
+ aDragPosition = MakePositionSticky(aDragPosition, bRTL ? GetLeftFrameMargin() : GetRightFrameMargin());
else
- aDragPosition = MakePositionSticky(aDragPosition, GetLeftFrameMargin());
+ aDragPosition = MakePositionSticky(aDragPosition, bRTL ? GetRightFrameMargin() : GetLeftFrameMargin());
const long lDiff = mpIndents[nIndex].nPos - aDragPosition;
@@ -1987,7 +1990,7 @@ void SvxRuler::DragObjectBorder()
void SvxRuler::ApplyMargins()
{
/* Applying margins; changed by dragging. */
- const SfxPoolItem *pItem = 0;
+ const SfxPoolItem* pItem = NULL;
sal_uInt16 nId = SID_ATTR_LONG_LRSPACE;
if(bHorz)
@@ -2062,135 +2065,105 @@ void SvxRuler::ApplyMargins()
long SvxRuler::RoundToCurrentMapMode(long lValue) const
{
RulerUnitData aUnitData = GetCurrentRulerUnit();
- long lNewValue = pEditWin->LogicToLogic(Size(lValue, 0), pEditWin->GetMapMode(), GetCurrentMapMode()).Width();
double aRoundingFactor = aUnitData.nTickUnit / aUnitData.nTick1;
+
+ long lNewValue = pEditWin->LogicToLogic(Size(lValue, 0), pEditWin->GetMapMode(), GetCurrentMapMode()).Width();
lNewValue = (std::round(lNewValue / (double) aUnitData.nTickUnit * aRoundingFactor) / aRoundingFactor) * aUnitData.nTickUnit;
return pEditWin->LogicToLogic(Size(lNewValue, 0), GetCurrentMapMode(), pEditWin->GetMapMode()).Width();
}
void SvxRuler::ApplyIndents()
{
- long nLeftFrameMargin = GetLeftFrameMargin();
- long nRightFrameMargin = GetRightFrameMargin();
+ /* Applying paragraph settings; changed by dragging. */
+
+ long nLeftFrameMargin = GetLeftFrameMargin();
bool bRTL = mpRulerImpl->pTextRTLItem && mpRulerImpl->pTextRTLItem->GetValue();
- /* Applying paragraph settings; changed by dragging. */
long nNewTxtLeft;
- if(mpColumnItem.get() && !IsActFirstColumn(sal_True))
- {
- long nLeftCol = GetActLeftColumn(sal_True);
- nNewTxtLeft =
- PixelHAdjust(
- ConvertHPosLogic(mpIndents[INDENT_LEFT_MARGIN].nPos) -
- (ConvertHPosLogic(mpBorders[nLeftCol].nPos) +
- ConvertHPosLogic(mpBorders[nLeftCol].nWidth)) -
- lAppNullOffset,
- mpParaItem->GetTxtLeft());
- }
- else
- {
- nNewTxtLeft = PixelHAdjust(
- ConvertHPosLogic(mpIndents[INDENT_LEFT_MARGIN].nPos),
- mpParaItem->GetTxtLeft());
- }
-
- if (mbSnapping)
- nNewTxtLeft = RoundToCurrentMapMode(nNewTxtLeft);
-
long nNewFirstLineOffset;
+ long nNewRight;
- if(bRTL)
+ long nFirstLine = ConvertPosLogic(mpIndents[INDENT_FIRST_LINE].nPos);
+ long nLeftMargin = ConvertPosLogic(mpIndents[INDENT_LEFT_MARGIN].nPos);
+ long nRightMargin = ConvertPosLogic(mpIndents[INDENT_RIGHT_MARGIN].nPos);
+
+ if(mpColumnItem.get() && ((bRTL && !IsActLastColumn(sal_True)) || (!bRTL && !IsActFirstColumn(sal_True))))
{
- nNewFirstLineOffset = PixelHAdjust(
- nRightFrameMargin -
- ConvertHPosLogic(mpIndents[INDENT_FIRST_LINE].nPos ) -
- lAppNullOffset,
- mpParaItem->GetTxtFirstLineOfst());
+ if(bRTL)
+ {
+ long nRightColumn = GetActRightColumn(sal_True);
+ long nRightBorder = ConvertPosLogic(mpBorders[nRightColumn].nPos);
+ nNewTxtLeft = nRightBorder - nLeftMargin - lAppNullOffset;
+ }
+ else
+ {
+ long nLeftColumn = GetActLeftColumn(sal_True);
+ long nLeftBorder = ConvertPosLogic(mpBorders[nLeftColumn].nPos + mpBorders[nLeftColumn].nWidth);
+ nNewTxtLeft = nLeftMargin - nLeftBorder - lAppNullOffset;
+ }
}
else
{
- nNewFirstLineOffset = PixelHAdjust(
- ConvertHPosLogic(mpIndents[INDENT_FIRST_LINE].nPos) -
- ConvertHPosLogic(mpIndents[INDENT_LEFT_MARGIN].nPos) -
- lAppNullOffset,
- mpParaItem->GetTxtFirstLineOfst());
- }
-
-
- // If the new TxtLeft is smaller than the old FirstLineIndent, then the
- // difference is lost and the paragraph is in total indented too far,
- // so first set the FirstLineOffset, then the TxtLeft
-
- if(bRTL)
- {
- nNewTxtLeft = nRightFrameMargin - nNewTxtLeft - nLeftFrameMargin;
- nNewFirstLineOffset -= nNewTxtLeft;
- if(mpParaBorderItem.get())
+ if(bRTL)
+ {
+ long nRightBorder = ConvertPosLogic(GetMargin2());
+ nNewTxtLeft = nRightBorder - nLeftMargin - lAppNullOffset;
+ }
+ else
{
- nNewTxtLeft += mpParaBorderItem->GetLeft() + mpParaBorderItem->GetRight();
- nNewFirstLineOffset -= mpParaBorderItem->GetRight();
+ long nLeftBorder = ConvertPosLogic(GetMargin1());
+ nNewTxtLeft = nLeftBorder + nLeftMargin - nLeftFrameMargin - lAppNullOffset;
}
}
- if (mbSnapping)
- nNewFirstLineOffset = RoundToCurrentMapMode(nNewFirstLineOffset);
-
- mpParaItem->SetTxtFirstLineOfst(sal::static_int_cast< short >(nNewFirstLineOffset));
- mpParaItem->SetTxtLeft(nNewTxtLeft);
-
- long nRight;
+ if(bRTL)
+ nNewFirstLineOffset = nLeftMargin - nFirstLine - lAppNullOffset;
+ else
+ nNewFirstLineOffset = nFirstLine - nLeftMargin - lAppNullOffset;
- if(mpColumnItem.get() && ((!bRTL && !IsActLastColumn( sal_True )) || (bRTL && !IsActFirstColumn())))
+ if(mpColumnItem.get() && ((!bRTL && !IsActLastColumn(sal_True)) || (bRTL && !IsActFirstColumn(sal_True))))
{
if(bRTL)
{
- long nActBorder = ConvertHPosLogic(mpBorders[GetActLeftColumn(sal_True)].nPos);
- long nRightMargin = ConvertHPosLogic(mpIndents[INDENT_RIGHT_MARGIN].nPos);
- long nConvert = nRightMargin - nActBorder;
-
- nRight = PixelHAdjust( nConvert - lAppNullOffset, mpParaItem->GetRight() );
+ long nLeftColumn = GetActLeftColumn(sal_True);
+ long nLeftBorder = ConvertPosLogic(mpBorders[nLeftColumn].nPos + mpBorders[nLeftColumn].nWidth);
+ nNewRight = nRightMargin - nLeftBorder - lAppNullOffset;
}
else
{
- nRight = PixelHAdjust(
- ConvertHPosLogic(mpBorders[GetActRightColumn(sal_True)].nPos) -
- ConvertHPosLogic(mpIndents[INDENT_RIGHT_MARGIN].nPos) -
- lAppNullOffset,
- mpParaItem->GetRight());
+ long nRightColumn = GetActRightColumn(sal_True);
+ long nRightBorder = ConvertPosLogic(mpBorders[nRightColumn].nPos);
+ nNewRight = nRightBorder - nRightMargin - lAppNullOffset;
}
}
else
{
if(bRTL)
{
- long lBorderLeft = mpParaBorderItem.get() ? mpParaBorderItem->GetLeft() : 0;
-
- nRight = PixelHAdjust(
- ConvertHPosLogic(GetMargin1()) +
- ConvertHPosLogic(mpIndents[INDENT_RIGHT_MARGIN].nPos) -
- GetLeftFrameMargin() +
- lBorderLeft -
- lAppNullOffset,
- mpParaItem->GetRight());
+ long nLeftBorder = ConvertPosLogic(GetMargin1());
+ nNewRight = nLeftBorder + nRightMargin - nLeftFrameMargin - lAppNullOffset;
}
else
{
- nRight = PixelHAdjust(
- ConvertHPosLogic(GetMargin2()) -
- ConvertHPosLogic(mpIndents[INDENT_RIGHT_MARGIN].nPos) -
- lAppNullOffset,
- mpParaItem->GetRight());
+ long nRightBorder = ConvertPosLogic(GetMargin2());
+ nNewRight = nRightBorder - nRightMargin - lAppNullOffset;
}
}
if (mbSnapping)
- nRight = RoundToCurrentMapMode(nRight);
+ {
+ nNewTxtLeft = RoundToCurrentMapMode(nNewTxtLeft);
+ nNewFirstLineOffset = RoundToCurrentMapMode(nNewFirstLineOffset);
+ nNewRight = RoundToCurrentMapMode(nNewRight);
+ }
- mpParaItem->SetRight( nRight );
+ mpParaItem->SetTxtFirstLineOfst(sal::static_int_cast<short>(nNewFirstLineOffset));
+ mpParaItem->SetTxtLeft(nNewTxtLeft);
+ mpParaItem->SetRight(nNewRight);
- sal_uInt16 nParaId = bHorz ? SID_ATTR_PARA_LRSPACE : SID_ATTR_PARA_LRSPACE_VERTICAL;
- pBindings->GetDispatcher()->Execute( nParaId, SFX_CALLMODE_RECORD, mpParaItem.get(), 0L );
+ sal_uInt16 nParagraphId = bHorz ? SID_ATTR_PARA_LRSPACE : SID_ATTR_PARA_LRSPACE_VERTICAL;
+ pBindings->GetDispatcher()->Execute( nParagraphId, SFX_CALLMODE_RECORD, mpParaItem.get(), 0L );
UpdateTabs();
}
@@ -2605,8 +2578,8 @@ void SvxRuler::Click()
}
}
-sal_Bool SvxRuler::CalcLimits ( long &nMax1, // minimum value to be set
- long &nMax2, // minimum value to be set
+sal_Bool SvxRuler::CalcLimits ( long& nMax1, // minimum value to be set
+ long& nMax2, // minimum value to be set
sal_Bool ) const
{
/*
@@ -3501,14 +3474,15 @@ sal_uInt16 SvxRuler::GetActRightColumn(
{
if( nAct == USHRT_MAX )
nAct = mpColumnItem->GetActColumn();
- else nAct++; //To be able to pass on the ActDrag
+ else
+ nAct++; //To be able to pass on the ActDrag
sal_Bool bConsiderHidden = !bForceDontConsiderHidden &&
- !( nDragType & DRAG_OBJECT_ACTLINE_ONLY );
+ !(nDragType & DRAG_OBJECT_ACTLINE_ONLY);
while( nAct < mpColumnItem->Count() - 1 )
{
- if( (*mpColumnItem.get())[nAct].bVisible || bConsiderHidden )
+ if (mpColumnItem->At(nAct).bVisible || bConsiderHidden)
return nAct;
else
nAct++;
@@ -3523,17 +3497,17 @@ sal_uInt16 SvxRuler::GetActLeftColumn(
if(nAct == USHRT_MAX)
nAct = mpColumnItem->GetActColumn();
- sal_uInt16 nLOffs = 1;
+ sal_uInt16 nLeftOffset = 1;
sal_Bool bConsiderHidden = !bForceDontConsiderHidden &&
- !( nDragType & DRAG_OBJECT_ACTLINE_ONLY );
+ !(nDragType & DRAG_OBJECT_ACTLINE_ONLY);
- while(nAct >= nLOffs)
+ while(nAct >= nLeftOffset)
{
- if( (*mpColumnItem.get())[nAct - nLOffs].bVisible || bConsiderHidden )
- return nAct-nLOffs;
+ if (mpColumnItem->At(nAct - nLeftOffset).bVisible || bConsiderHidden)
+ return nAct - nLeftOffset;
else
- nLOffs++;
+ nLeftOffset++;
}
return USHRT_MAX;
}
commit 47a77d7dbc427e51421e2df8d59695834cb74980
Author: Tomaž Vajngerl <quikee at gmail.com>
Date: Tue Sep 10 08:33:24 2013 +0200
Ruler: disable snapping, tooltips
It is now possible to disable snapping of the ruler at dragging
with holding the ALT key and coarse snapping with ALT+SHIFT key.
Tooltips are shown when hovering over indents and borders.
Change-Id: Ib1e9639e1e2824f2a75b5abd35765bbbd02c87f7
diff --git a/include/svtools/ruler.hxx b/include/svtools/ruler.hxx
index 77cc958..9382cb0 100644
--- a/include/svtools/ruler.hxx
+++ b/include/svtools/ruler.hxx
@@ -474,16 +474,11 @@ Tips zur Benutzung des Lineals:
*************************************************************************/
-// -----------
// - WinBits -
-// -----------
-
-#define WB_EXTRAFIELD ((WinBits)0x00004000)
-#define WB_RIGHT_ALIGNED ((WinBits)0x00008000)
-#define WB_STDRULER WB_HORZ
-
-struct ImplRulerHitTest;
+#define WB_EXTRAFIELD ((WinBits)0x00004000)
+#define WB_RIGHT_ALIGNED ((WinBits)0x00008000)
+#define WB_STDRULER WB_HORZ
// - Ruler-Type -
@@ -541,7 +536,7 @@ struct RulerBorder
struct RulerIndent
{
- long nPos;
+ long nPos;
sal_uInt16 nStyle;
};
@@ -572,6 +567,21 @@ struct RulerLine
sal_uInt16 nStyle;
};
+struct RulerSelection
+{
+ long nPos;
+ RulerType eType;
+ sal_uInt16 nAryPos;
+ sal_uInt16 mnDragSize;
+ bool bSize;
+ bool bSizeBar;
+ bool bExpandTest;
+
+ RulerSelection() :
+ bExpandTest( false )
+ {}
+};
+
struct RulerUnitData
{
MapUnit eMapUnit; // MAP_UNIT for calculaion
@@ -635,6 +645,9 @@ private:
sal_Bool mbAutoWinWidth;
sal_Bool mbActive;
sal_uInt8 mnUpdateFlags;
+
+ RulerSelection maHoverSelection;
+
Link maStartDragHdl;
Link maDragHdl;
Link maEndDragHdl;
@@ -642,8 +655,8 @@ private:
Link maDoubleClickHdl;
Link maExtraDownHdl;
- boost::scoped_ptr<ImplRulerHitTest> mpCurrentHitTest;
- boost::scoped_ptr<ImplRulerHitTest> mpPreviousHitTest;
+ boost::scoped_ptr<RulerSelection> mpCurrentHitTest;
+ boost::scoped_ptr<RulerSelection> mpPreviousHitTest;
SVT_DLLPRIVATE void ImplVDrawLine( long nX1, long nY1, long nX2, long nY2 );
SVT_DLLPRIVATE void ImplVDrawRect( long nX1, long nY1, long nX2, long nY2 );
@@ -669,11 +682,11 @@ private:
using Window::ImplHitTest;
SVT_DLLPRIVATE sal_Bool ImplHitTest( const Point& rPosition,
- ImplRulerHitTest* pHitTest,
+ RulerSelection* pHitTest,
sal_Bool bRequiredStyle = sal_False,
sal_uInt16 nRequiredStyle = 0 ) const;
- SVT_DLLPRIVATE sal_Bool ImplDocHitTest( const Point& rPos, RulerType eDragType, ImplRulerHitTest* pHitTest ) const;
- SVT_DLLPRIVATE sal_Bool ImplStartDrag( ImplRulerHitTest* pHitTest, sal_uInt16 nModifier );
+ SVT_DLLPRIVATE sal_Bool ImplDocHitTest( const Point& rPos, RulerType eDragType, RulerSelection* pHitTest ) const;
+ SVT_DLLPRIVATE sal_Bool ImplStartDrag( RulerSelection* pHitTest, sal_uInt16 nModifier );
SVT_DLLPRIVATE void ImplDrag( const Point& rPos );
SVT_DLLPRIVATE void ImplEndDrag();
@@ -751,6 +764,8 @@ public:
RulerType GetClickType() const { return meDragType; }
sal_uInt16 GetClickAryPos() const { return mnDragAryPos; }
+ RulerSelection GetHoverSelection() const { return maHoverSelection; }
+
using Window::GetType;
RulerType GetType( const Point& rPos, sal_uInt16* pAryPos = NULL ) const;
diff --git a/include/svx/ruler.hxx b/include/svx/ruler.hxx
index 1044c89..55dea87 100644
--- a/include/svx/ruler.hxx
+++ b/include/svx/ruler.hxx
@@ -101,6 +101,9 @@ class SVX_DLLPUBLIC SvxRuler: public Ruler, public SfxListener
sal_Bool bListening;
sal_Bool bActive;
+ bool mbCoarseSnapping;
+ bool mbSnapping;
+
void StartListening_Impl();
long GetCorrectedDragPos(sal_Bool bLeft = sal_True, sal_Bool bRight = sal_True );
void DrawLine_Impl(long &lTabPos, int, sal_Bool Horizontal=sal_True);
@@ -135,7 +138,7 @@ class SVX_DLLPUBLIC SvxRuler: public Ruler, public SfxListener
void UpdateObject();
// Convert position to stick to ruler ticks
- long MakePositionSticky(long rValue, bool aSnapToFrameMargin = true) const;
+ long MakePositionSticky(long rValue, long aPointOfReference, bool aSnapToFrameMargin = true) const;
long PixelHAdjust(long lPos, long lPos2) const;
long PixelVAdjust(long lPos, long lPos2) const;
@@ -157,6 +160,8 @@ class SVX_DLLPUBLIC SvxRuler: public Ruler, public SfxListener
long ConvertPosLogic(long lPos) const;
long ConvertSizeLogic(long lSize) const;
+ long RoundToCurrentMapMode(long lValue) const;
+
long GetFirstLineIndent() const;
long GetLeftIndent() const;
long GetRightIndent() const;
diff --git a/svtools/source/control/ruler.cxx b/svtools/source/control/ruler.cxx
index b521564..3593fe9 100644
--- a/svtools/source/control/ruler.cxx
+++ b/svtools/source/control/ruler.cxx
@@ -100,21 +100,6 @@ public:
ImplRulerData& operator=( const ImplRulerData& rData );
};
-struct ImplRulerHitTest
-{
- long nPos;
- RulerType eType;
- sal_uInt16 nAryPos;
- sal_uInt16 mnDragSize;
- bool bSize;
- bool bSizeBar;
- bool bExpandTest;
-
- ImplRulerHitTest() :
- bExpandTest( false )
- {}
-};
-
ImplRulerData::ImplRulerData() :
nNullVirOff (0),
nRulVirOff (0),
@@ -435,7 +420,7 @@ void Ruler::ImplInvertLines( sal_Bool bErase )
void Ruler::ImplDrawTicks( long nMin, long nMax, long nStart, long nTop, long nBottom )
{
- long nCenter = nTop + ((nBottom - nTop) / 2);
+ double nCenter = nTop + ((nBottom - nTop) / 2);
long nTickLength3 = (nBottom - nTop) * 0.5;
long nTickLength2 = nTickLength3 * 0.66;
@@ -626,7 +611,7 @@ void Ruler::ImplDrawTicks( long nMin, long nMax, long nStart, long nTop, long nB
(nTickLength == nTickLength2 && nTickGap2 > 6) ||
(nTickLength == nTickLength3 && nTickGap3 > 6) )
{
- long nT1 = nCenter - (nTickLength / 2);
+ long nT1 = nCenter - (nTickLength / 2.0);
long nT2 = nT1 + nTickLength - 1;
long nT;
@@ -1410,7 +1395,7 @@ void Ruler::ImplUpdate( sal_Bool bMustCalc )
}
}
-sal_Bool Ruler::ImplHitTest( const Point& rPos, ImplRulerHitTest* pHitTest,
+sal_Bool Ruler::ImplHitTest( const Point& rPos, RulerSelection* pHitTest,
sal_Bool bRequireStyle, sal_uInt16 nRequiredStyle ) const
{
sal_Int32 i;
@@ -1713,7 +1698,7 @@ sal_Bool Ruler::ImplHitTest( const Point& rPos, ImplRulerHitTest* pHitTest,
}
sal_Bool Ruler::ImplDocHitTest( const Point& rPos, RulerType eDragType,
- ImplRulerHitTest* pHitTest ) const
+ RulerSelection* pHitTest ) const
{
Point aPos = rPos;
sal_Bool bRequiredStyle = sal_False;
@@ -1780,7 +1765,7 @@ sal_Bool Ruler::ImplDocHitTest( const Point& rPos, RulerType eDragType,
return sal_False;
}
-sal_Bool Ruler::ImplStartDrag( ImplRulerHitTest* pHitTest, sal_uInt16 nModifier )
+sal_Bool Ruler::ImplStartDrag( RulerSelection* pHitTest, sal_uInt16 nModifier )
{
// don't trigger drag if a border that was clicked can not be changed
if ( (pHitTest->eType == RULER_TYPE_BORDER) &&
@@ -1972,7 +1957,7 @@ void Ruler::MouseButtonDown( const MouseEvent& rMEvt )
}
else
{
- boost::scoped_ptr<ImplRulerHitTest> pHitTest(new ImplRulerHitTest);
+ boost::scoped_ptr<RulerSelection> pHitTest(new RulerSelection);
bool bHitTestResult = ImplHitTest(aMousePos, pHitTest.get());
if ( nMouseClicks == 1 )
@@ -2019,10 +2004,14 @@ void Ruler::MouseMove( const MouseEvent& rMEvt )
{
PointerStyle ePtrStyle = POINTER_ARROW;
- mpCurrentHitTest.reset(new ImplRulerHitTest);
+ mpCurrentHitTest.reset(new RulerSelection);
+
+ maHoverSelection.eType = RULER_TYPE_DONTKNOW;
if (ImplHitTest( rMEvt.GetPosPixel(), mpCurrentHitTest.get() ))
{
+ maHoverSelection = *mpCurrentHitTest.get();
+
if (mpCurrentHitTest->bSize)
{
if (mnWinStyle & WB_HORZ)
@@ -2280,10 +2269,11 @@ sal_Bool Ruler::StartDocDrag( const MouseEvent& rMEvt, RulerType eDragType )
{
if ( !mbDrag )
{
- Point aMousePos = rMEvt.GetPosPixel();
- sal_uInt16 nMouseClicks = rMEvt.GetClicks();
- sal_uInt16 nMouseModifier = rMEvt.GetModifier();
- ImplRulerHitTest aHitTest;
+ Point aMousePos = rMEvt.GetPosPixel();
+ sal_uInt16 nMouseClicks = rMEvt.GetClicks();
+ sal_uInt16 nMouseModifier = rMEvt.GetModifier();
+ RulerSelection aHitTest;
+
if(eDragType != RULER_TYPE_DONTKNOW)
aHitTest.bExpandTest = true;
@@ -2351,7 +2341,7 @@ void Ruler::CancelDrag()
RulerType Ruler::GetType( const Point& rPos, sal_uInt16* pAryPos ) const
{
- ImplRulerHitTest aHitTest;
+ RulerSelection aHitTest;
// update ruler
if ( IsReallyVisible() && mbFormat )
diff --git a/svx/source/dialog/svxruler.cxx b/svx/source/dialog/svxruler.cxx
index 59ab709..f4d0929 100644
--- a/svx/source/dialog/svxruler.cxx
+++ b/svx/source/dialog/svxruler.cxx
@@ -35,6 +35,8 @@
#include <editeng/lrspitem.hxx>
#include <editeng/protitem.hxx>
+#include <svx/svdtrans.hxx>
+
#include "rlrcitem.hxx"
#ifndef RULER_TAB_RTL
@@ -203,7 +205,7 @@ SvxRuler::SvxRuler(
SfxBindings &rBindings, // associated Bindings
WinBits nWinStyle) : // StarView WinBits
Ruler(pParent, nWinStyle),
- pCtrlItem(new SvxRulerItem *[CTRL_ITEM_COUNT]),
+ pCtrlItem(new SvxRulerItem* [CTRL_ITEM_COUNT]),
pEditWin(pWin),
mpRulerImpl(new SvxRuler_Impl),
bAppSetNullOffset(sal_False), // Is the 0-offset of the ruler set by the application?
@@ -226,7 +228,10 @@ SvxRuler::SvxRuler(
nMaxRight(0),
bValid(sal_False),
bListening(sal_False),
- bActive(sal_True)
+ bActive(sal_True),
+ mbCoarseSnapping(false),
+ mbSnapping(true)
+
{
/* Constructor; Initialize data buffer; controller items are created */
@@ -301,7 +306,7 @@ SvxRuler::SvxRuler(
}
}
- pCtrlItem[i++] = new SvxRulerItem( SID_RULER_PROTECT, *this, rBindings );
+ pCtrlItem[i++] = new SvxRulerItem(SID_RULER_PROTECT, *this, rBindings );
pCtrlItem[i++] = new SvxRulerItem(SID_RULER_BORDER_DISTANCE, *this, rBindings);
mpRulerImpl->nControlerItems=i;
@@ -311,7 +316,6 @@ SvxRuler::SvxRuler(
rBindings.LeaveRegistrations();
}
-
SvxRuler::~SvxRuler()
{
/* Destructor ruler; release internal buffer */
@@ -328,37 +332,44 @@ SvxRuler::~SvxRuler()
pBindings->LeaveRegistrations();
}
-long SvxRuler::MakePositionSticky(long aPosition, bool aSnapToFrameMargin) const
+long SvxRuler::MakePositionSticky(long aPosition, long aPointOfReference, bool aSnapToFrameMargin) const
{
- long aLeftFramePosition = ConvertHPosPixel(GetLeftFrameMargin());
- long aRightFramePosition = ConvertHPosPixel(GetRightFrameMargin());
+ long aPointOfReferencePixel = ConvertHPosPixel(aPointOfReference);
+ long aLeftFramePosition = ConvertHPosPixel(GetLeftFrameMargin());
+ long aRightFramePosition = ConvertHPosPixel(GetRightFrameMargin());
double aTick = GetCurrentRulerUnit().nTick1;
- long aTickPixel = pEditWin->LogicToPixel(Size(0, aTick), GetCurrentMapMode()).Height();
- double aHalfTick = aTick / 2;
- double aHalfTickPixel = aTickPixel / 2;
+
+ if (mbCoarseSnapping)
+ aTick = GetCurrentRulerUnit().nTick2;
+
+ long aTickPixel = pEditWin->LogicToPixel(Size(aTick, 0), GetCurrentMapMode()).Width();
+
+ double aHalfTick = aTick / 2.0;
+ double aHalfTickPixel = aTickPixel / 2.0;
if (aSnapToFrameMargin)
{
if (aPosition > aLeftFramePosition - aHalfTickPixel && aPosition < aLeftFramePosition + aHalfTickPixel)
- {
return aLeftFramePosition;
- }
- else if (aPosition > aRightFramePosition - aHalfTickPixel && aPosition < aRightFramePosition + aHalfTickPixel)
- {
+
+ if (aPosition > aRightFramePosition - aHalfTickPixel && aPosition < aRightFramePosition + aHalfTickPixel)
return aRightFramePosition;
- }
}
+ if (!mbSnapping)
+ return aPosition;
+
// Move "coordinate system" to frame position so ticks are calculated correctly
- long aTranslatedPosition = aPosition - aLeftFramePosition;
+ long aTranslatedPosition = aPosition - aPointOfReferencePixel;
// Convert position to current selected map mode
- long aPositionLogic = pEditWin->PixelToLogic(Size(0, aTranslatedPosition), GetCurrentMapMode()).Height();
- aPositionLogic = std::floor((aPositionLogic + aHalfTick) / aTick) * aTick;
+ long aPositionLogic = pEditWin->PixelToLogic(Size(aTranslatedPosition, 0), GetCurrentMapMode()).Width();
+ // Normalize -- snap to nearest tick
+ aPositionLogic = std::round((aPositionLogic + aHalfTick) / aTick) * aTick;
// Convert back to pixels
- aPosition = pEditWin->LogicToPixel(Size(0, aPositionLogic), GetCurrentMapMode()).Height();
+ aPosition = pEditWin->LogicToPixel(Size(aPositionLogic, 0), GetCurrentMapMode()).Width();
// Move "coordinate system" back to original position
- return aPosition + aLeftFramePosition;
+ return aPosition + aPointOfReferencePixel;
}
long SvxRuler::ConvertHPosPixel(long nVal) const
@@ -421,12 +432,12 @@ inline long SvxRuler::ConvertSizeLogic(long nVal) const
return bHorz? ConvertHSizeLogic(nVal): ConvertVSizeLogic(nVal);
}
-long SvxRuler::PixelHAdjust(long nVal, long nValOld) const
+long SvxRuler::PixelHAdjust(long nVal, long /*nValOld*/) const
{
- if(ConvertHSizePixel(nVal) != ConvertHSizePixel(nValOld))
+ //if(ConvertHSizePixel(nVal) != ConvertHSizePixel(nValOld))
return nVal;
- else
- return nValOld;
+ //else
+ // return nValOld;
}
long SvxRuler::PixelVAdjust(long nVal, long nValOld) const
@@ -539,7 +550,100 @@ void SvxRuler::MouseMove( const MouseEvent& rMEvt )
pBindings->Update( SID_RULER_OBJECT );
pBindings->Update( SID_RULER_PROTECT );
}
+
Ruler::MouseMove( rMEvt );
+
+ RulerSelection aSelection = GetHoverSelection();
+
+ if (aSelection.eType == RULER_TYPE_DONTKNOW)
+ {
+ SetQuickHelpText("");
+ return;
+ }
+
+ RulerUnitData aUnitData = GetCurrentRulerUnit();
+ double aRoundingFactor = aUnitData.nTickUnit / aUnitData.nTick1;
+ sal_Int32 aNoDecimalPlaces = 1 + std::ceil(std::log10(aRoundingFactor));
+ OUString sUnit = OUString::createFromAscii(aUnitData.aUnitStr);
+
+ switch (aSelection.eType)
+ {
+ case RULER_TYPE_INDENT:
+ {
+ long nIndex = aSelection.nAryPos + INDENT_GAP;
+
+ long nIndentValue = 0.0;
+ if (nIndex == INDENT_LEFT_MARGIN)
+ nIndentValue = mpParaItem->GetTxtLeft();
+ else if (nIndex == INDENT_FIRST_LINE)
+ nIndentValue = mpParaItem->GetTxtFirstLineOfst();
+ else if (nIndex == INDENT_RIGHT_MARGIN)
+ nIndentValue = mpParaItem->GetRight();
+
+ double fValue = pEditWin->LogicToLogic(Size(nIndentValue, 0), pEditWin->GetMapMode(), GetCurrentMapMode()).Width();
+ fValue = rtl::math::round(fValue / aUnitData.nTickUnit, aNoDecimalPlaces);
+
+ SetQuickHelpText(OUString::number(fValue) + " " + sUnit);
+ break;
+ }
+ case RULER_TYPE_BORDER:
+ {
+ if (mpColumnItem.get() == NULL)
+ break;
+
+ SvxColumnItem& aColumnItem = *mpColumnItem.get();
+
+ if (aSelection.nAryPos + 1 >= aColumnItem.Count())
+ break;
+
+ double fStart = pEditWin->LogicToLogic(Size(aColumnItem[aSelection.nAryPos].nEnd, 0), pEditWin->GetMapMode(), GetCurrentMapMode()).Width();
+ fStart = rtl::math::round(fStart / aUnitData.nTickUnit, aNoDecimalPlaces);
+ double fEnd = pEditWin->LogicToLogic(Size(aColumnItem[aSelection.nAryPos + 1].nStart, 0), pEditWin->GetMapMode(), GetCurrentMapMode()).Width();
+ fEnd = rtl::math::round(fEnd / aUnitData.nTickUnit, aNoDecimalPlaces);
+
+ SetQuickHelpText(
+ OUString::number(fStart) + " " + sUnit + " - " +
+ OUString::number(fEnd) + " " + sUnit );
+ break;
+ }
+ case RULER_TYPE_MARGIN1:
+ {
+ long nLeft = 0.0;
+ if (mpLRSpaceItem.get())
+ nLeft = mpLRSpaceItem->GetLeft();
+ else if (mpULSpaceItem.get())
+ nLeft = mpULSpaceItem->GetUpper();
+ else
+ break;
+
+ double fValue = pEditWin->LogicToLogic(Size(nLeft, 0), pEditWin->GetMapMode(), GetCurrentMapMode()).Width();
+ fValue = rtl::math::round(fValue / aUnitData.nTickUnit, aNoDecimalPlaces);
+ SetQuickHelpText(OUString::number(fValue) + " " + sUnit);
+
+ break;
+ }
+ case RULER_TYPE_MARGIN2:
+ {
+ long nRight = 0.0;
+ if (mpLRSpaceItem.get())
+ nRight = mpLRSpaceItem->GetRight();
+ else if (mpULSpaceItem.get())
+ nRight = mpULSpaceItem->GetLower();
+ else
+ break;
+
+ double fValue = pEditWin->LogicToLogic(Size(nRight, 0), pEditWin->GetMapMode(), GetCurrentMapMode()).Width();
+ fValue = rtl::math::round(fValue / aUnitData.nTickUnit, aNoDecimalPlaces);
+ SetQuickHelpText(OUString::number(fValue) + " " + sUnit);
+
+ break;
+ }
+ default:
+ {
+ SetQuickHelpText("");
+ break;
+ }
+ }
}
void SvxRuler::StartListening_Impl()
@@ -733,11 +837,9 @@ void SvxRuler::UpdatePara()
Left margin, first line indent, right margin paragraph update
mpIndents[0] = Buffer for old intent
mpIndents[1] = Buffer for old intent
- mpIndents[INDENT_FIRST_LINE] = First line indent
- mpIndents[3] = left margin
- mpIndents[4] = right margin
- mpIndents[5] = left border distance
- mpIndents[6] = right border distance
+ mpIndents[INDENT_FIRST_LINE] = first line indent
+ mpIndents[INDENT_LEFT_MARGIN] = left margin
+ mpIndents[INDENT_RIGHT_MARGIN] = right margin
*/
// Dependence on PagePosItem
@@ -750,45 +852,32 @@ void SvxRuler::UpdatePara()
SetLeftFrameMargin(ConvertHPosPixel(nLeftFrameMargin));
SetRightFrameMargin(ConvertHPosPixel(nRightFrameMargin));
+ long leftMargin;
+ long leftFirstLine;
+ long rightMargin;
+
if(bRTLText)
{
- mpIndents[INDENT_FIRST_LINE].nPos = ConvertHPosPixel(
- nRightFrameMargin - mpParaItem->GetTxtLeft() - mpParaItem->GetTxtFirstLineOfst() + lAppNullOffset );
+ leftMargin = nRightFrameMargin - mpParaItem->GetTxtLeft() + lAppNullOffset;
+ leftFirstLine = leftMargin - mpParaItem->GetTxtFirstLineOfst();
+ rightMargin = nLeftFrameMargin + mpParaItem->GetRight() + lAppNullOffset;
}
else
{
- mpIndents[INDENT_FIRST_LINE].nPos =
- ConvertHPosPixel(
- nLeftFrameMargin + mpParaItem->GetTxtLeft() + mpParaItem->GetTxtFirstLineOfst() + lAppNullOffset);
+ leftMargin = nLeftFrameMargin + mpParaItem->GetTxtLeft() + lAppNullOffset;
+ leftFirstLine = leftMargin + mpParaItem->GetTxtFirstLineOfst();
+ rightMargin = nRightFrameMargin - mpParaItem->GetRight() + lAppNullOffset;
}
+
+ mpIndents[INDENT_LEFT_MARGIN].nPos = ConvertHPosPixel(leftMargin);
+ mpIndents[INDENT_FIRST_LINE].nPos = ConvertHPosPixel(leftFirstLine);
+ mpIndents[INDENT_RIGHT_MARGIN].nPos = ConvertHPosPixel(rightMargin);
+
if( mpParaItem->IsAutoFirst() )
mpIndents[INDENT_FIRST_LINE].nStyle |= RULER_STYLE_INVISIBLE;
else
mpIndents[INDENT_FIRST_LINE].nStyle &= ~RULER_STYLE_INVISIBLE;
- if(bRTLText)
- {
- // left margin
- mpIndents[INDENT_LEFT_MARGIN].nPos =
- ConvertHPosPixel(nRightFrameMargin - mpParaItem->GetTxtLeft() + lAppNullOffset);
-
- // right margin
- mpIndents[INDENT_RIGHT_MARGIN].nPos =
- ConvertHPosPixel(nLeftFrameMargin + mpParaItem->GetRight() + lAppNullOffset);
-
- }
- else
- {
- // left margin
- sal_Int32 leftMargin =
- ConvertHPosPixel(nLeftFrameMargin + mpParaItem->GetTxtLeft() + lAppNullOffset);
- mpIndents[INDENT_LEFT_MARGIN].nPos = leftMargin;
-
- // right margin, always negative to the right edge of the surrounding frames
- sal_Int32 rightMargin =
- ConvertHPosPixel(nRightFrameMargin - mpParaItem->GetRight() + lAppNullOffset);
- mpIndents[INDENT_RIGHT_MARGIN].nPos = rightMargin;
- }
SetIndents(INDENT_COUNT, mpIndents.get() + INDENT_GAP);
}
else
@@ -799,7 +888,7 @@ void SvxRuler::UpdatePara()
mpIndents[INDENT_LEFT_MARGIN].nPos = 0;
mpIndents[INDENT_RIGHT_MARGIN].nPos = 0;
}
- SetIndents(); // turn off
+ SetIndents(); // turn off
}
}
@@ -1183,7 +1272,6 @@ long SvxRuler::GetRightIndent() const
return mpParaItem.get() ? mpIndents[INDENT_RIGHT_MARGIN].nPos : GetMargin2();
}
-
long SvxRuler::GetLogicRightIndent() const
{
/* Get Right paragraph margin in Logic */
@@ -1200,12 +1288,11 @@ long SvxRuler::GetLeftFrameMargin() const
long nLeft = 0;
if (mpColumnItem.get() &&
mpColumnItem->Count() &&
- mpColumnItem->GetActColumn() < mpColumnItem->Count())
+ mpColumnItem->IsConsistent())
{
- nLeft = (*mpColumnItem.get())[mpColumnItem->GetActColumn()].nStart;
+ nLeft = mpColumnItem->GetActiveColumnDescription().nStart;
}
- if(mpParaBorderItem.get() && (!mpColumnItem || mpColumnItem->IsTable()))
- nLeft += mpParaBorderItem->GetLeft();
+
return nLeft;
}
@@ -1305,7 +1392,8 @@ void SvxRuler::DragMargin1()
{
/* Dragging the left edge of frame */
long aDragPosition = GetCorrectedDragPos( !TAB_FLAG || !NEG_FLAG, sal_True );
- aDragPosition = MakePositionSticky(aDragPosition, false);
+
+ aDragPosition = MakePositionSticky(aDragPosition, GetRightFrameMargin(), false);
// Check if position changed
if (aDragPosition == 0)
@@ -1435,7 +1523,7 @@ void SvxRuler::DragMargin2()
{
/* Dragging the right edge of frame */
long aDragPosition = GetCorrectedDragPos( sal_True, !TAB_FLAG || !NEG_FLAG);
- aDragPosition = MakePositionSticky(aDragPosition, false);
+ aDragPosition = MakePositionSticky(aDragPosition, GetLeftFrameMargin(), false);
long lDiff = aDragPosition - GetMargin2();
// Check if position changed
@@ -1474,7 +1562,10 @@ void SvxRuler::DragIndents()
long aDragPosition = NEG_FLAG ? GetDragPos() : GetCorrectedDragPos();
const sal_uInt16 nIndex = GetDragAryPos() + INDENT_GAP;
- aDragPosition = MakePositionSticky(aDragPosition);
+ if(nIndex == INDENT_RIGHT_MARGIN)
+ aDragPosition = MakePositionSticky(aDragPosition, GetRightFrameMargin());
+ else
+ aDragPosition = MakePositionSticky(aDragPosition, GetLeftFrameMargin());
const long lDiff = mpIndents[nIndex].nPos - aDragPosition;
@@ -1514,7 +1605,7 @@ void SvxRuler::DrawLine_Impl(long& lTabPosition, int nNew, sal_Bool bHorizontal)
if( nNew & 1 )
{
long nDrapPosition = GetCorrectedDragPos( ( nNew & 4 ) != 0, ( nNew & 2 ) != 0 );
- nDrapPosition = MakePositionSticky(nDrapPosition);
+ nDrapPosition = MakePositionSticky(nDrapPosition, GetLeftFrameMargin());
lTabPosition = ConvertHSizeLogic( nDrapPosition + GetNullOffset() );
if(mpPagePosItem.get())
lTabPosition += mpPagePosItem->GetPos().X();
@@ -1539,7 +1630,7 @@ void SvxRuler::DrawLine_Impl(long& lTabPosition, int nNew, sal_Bool bHorizontal)
if(nNew & 1)
{
long nDrapPosition = GetCorrectedDragPos();
- nDrapPosition = MakePositionSticky(nDrapPosition);
+ nDrapPosition = MakePositionSticky(nDrapPosition, GetLeftFrameMargin());
lTabPosition = ConvertVSizeLogic(nDrapPosition + GetNullOffset());
if(mpPagePosItem.get())
lTabPosition += mpPagePosItem->GetPos().Y();
@@ -1555,7 +1646,7 @@ void SvxRuler::DragTabs()
{
/* Dragging of Tabs */
long aDragPosition = GetCorrectedDragPos(sal_True, sal_False);
- aDragPosition = MakePositionSticky(aDragPosition);
+ aDragPosition = MakePositionSticky(aDragPosition, GetLeftFrameMargin());
sal_uInt16 nIdx = GetDragAryPos() + TAB_GAP;
long nDiff = aDragPosition - mpTabs[nIdx].nPos;
@@ -1680,7 +1771,7 @@ void SvxRuler::DragBorders()
long lDiff = 0;
// the drag position has to be corrected to be able to prevent borders from passing each other
- long lPos = MakePositionSticky(GetCorrectedDragPos());
+ long lPos = MakePositionSticky(GetCorrectedDragPos(), GetLeftFrameMargin());
switch(nDragSize)
{
@@ -1883,7 +1974,7 @@ void SvxRuler::DragObjectBorder()
/* Dragging of object edges */
if(RULER_DRAGSIZE_MOVE == GetDragSize())
{
- const long lPosition = MakePositionSticky(GetCorrectedDragPos());
+ const long lPosition = MakePositionSticky(GetCorrectedDragPos(), GetLeftFrameMargin());
const sal_uInt16 nIdx = GetDragAryPos();
mpObjectBorders[GetObjectBordersOff(nIdx)].nPos = lPosition;
@@ -1898,41 +1989,55 @@ void SvxRuler::ApplyMargins()
/* Applying margins; changed by dragging. */
const SfxPoolItem *pItem = 0;
sal_uInt16 nId = SID_ATTR_LONG_LRSPACE;
+
if(bHorz)
{
const long lOldNull = lLogicNullOffset;
- if(mpRulerImpl->lMaxLeftLogic!=-1&&nMaxLeft==GetMargin1()+Ruler::GetNullOffset())
- mpLRSpaceItem->SetLeft(lLogicNullOffset=mpRulerImpl->lMaxLeftLogic);
+ if(mpRulerImpl->lMaxLeftLogic != -1 && nMaxLeft == GetMargin1() + Ruler::GetNullOffset())
+ {
+ lLogicNullOffset = mpRulerImpl->lMaxLeftLogic;
+ mpLRSpaceItem->SetLeft(lLogicNullOffset);
+ }
else
- mpLRSpaceItem->SetLeft(PixelHAdjust(
- lLogicNullOffset = ConvertHPosLogic(GetFrameLeft()) -
- lAppNullOffset, mpLRSpaceItem->GetLeft()));
+ {
+ lLogicNullOffset = ConvertHPosLogic(GetFrameLeft()) - lAppNullOffset;
+ mpLRSpaceItem->SetLeft(PixelHAdjust(lLogicNullOffset, mpLRSpaceItem->GetLeft()));
+ }
if(bAppSetNullOffset)
lAppNullOffset += lLogicNullOffset - lOldNull;
- if(mpRulerImpl->lMaxRightLogic!=-1
- &&nMaxRight==GetMargin2()+Ruler::GetNullOffset())
- mpLRSpaceItem->SetRight(GetPageWidth()-mpRulerImpl->lMaxRightLogic);
+ long nRight;
+ if(mpRulerImpl->lMaxRightLogic != -1
+ && nMaxRight == GetMargin2() + Ruler::GetNullOffset())
+ {
+ nRight = GetPageWidth() - mpRulerImpl->lMaxRightLogic;
+ }
else
- mpLRSpaceItem->SetRight(
- PixelHAdjust(
- std::max((long)0,mpPagePosItem->GetWidth() -
- mpLRSpaceItem->GetLeft() -
- (ConvertHPosLogic(GetMargin2()) -
- lAppNullOffset)),mpLRSpaceItem->GetRight()));
+ {
+ nRight = std::max((long)0,
+ mpPagePosItem->GetWidth() - mpLRSpaceItem->GetLeft() -
+ (ConvertHPosLogic(GetMargin2()) - lAppNullOffset));
+
+ nRight = PixelHAdjust( nRight, mpLRSpaceItem->GetRight());
+ }
+ mpLRSpaceItem->SetRight(nRight);
+
pItem = mpLRSpaceItem.get();
+
#ifdef DEBUGLIN
Debug_Impl(pEditWin, *mpLRSpaceItem);
#endif // DEBUGLIN
+
}
- else {
+ else
+ {
const long lOldNull = lLogicNullOffset;
mpULSpaceItem->SetUpper(
PixelVAdjust(
lLogicNullOffset =
ConvertVPosLogic(GetFrameLeft()) -
- lAppNullOffset,mpULSpaceItem->GetUpper()));
+ lAppNullOffset, mpULSpaceItem->GetUpper()));
if(bAppSetNullOffset)
lAppNullOffset += lLogicNullOffset - lOldNull;
mpULSpaceItem->SetLower(
@@ -1940,20 +2045,36 @@ void SvxRuler::ApplyMargins()
std::max((long)0, mpPagePosItem->GetHeight() -
mpULSpaceItem->GetUpper() -
(ConvertVPosLogic(GetMargin2()) -
- lAppNullOffset)),mpULSpaceItem->GetLower()));
+ lAppNullOffset)), mpULSpaceItem->GetLower()));
pItem = mpULSpaceItem.get();
nId = SID_ATTR_LONG_ULSPACE;
+
#ifdef DEBUGLIN
Debug_Impl(pEditWin,*mpULSpaceItem.get());
#endif // DEBUGLIN
+
}
pBindings->GetDispatcher()->Execute( nId, SFX_CALLMODE_RECORD, pItem, 0L );
if(mpTabStopItem.get())
UpdateTabs();
}
+long SvxRuler::RoundToCurrentMapMode(long lValue) const
+{
+ RulerUnitData aUnitData = GetCurrentRulerUnit();
+ long lNewValue = pEditWin->LogicToLogic(Size(lValue, 0), pEditWin->GetMapMode(), GetCurrentMapMode()).Width();
+ double aRoundingFactor = aUnitData.nTickUnit / aUnitData.nTick1;
+ lNewValue = (std::round(lNewValue / (double) aUnitData.nTickUnit * aRoundingFactor) / aRoundingFactor) * aUnitData.nTickUnit;
+ return pEditWin->LogicToLogic(Size(lNewValue, 0), GetCurrentMapMode(), pEditWin->GetMapMode()).Width();
+}
+
void SvxRuler::ApplyIndents()
{
+ long nLeftFrameMargin = GetLeftFrameMargin();
+ long nRightFrameMargin = GetRightFrameMargin();
+
+ bool bRTL = mpRulerImpl->pTextRTLItem && mpRulerImpl->pTextRTLItem->GetValue();
+
/* Applying paragraph settings; changed by dragging. */
long nNewTxtLeft;
if(mpColumnItem.get() && !IsActFirstColumn(sal_True))
@@ -1961,10 +2082,9 @@ void SvxRuler::ApplyIndents()
long nLeftCol = GetActLeftColumn(sal_True);
nNewTxtLeft =
PixelHAdjust(
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list